GithubHelp home page GithubHelp logo

Comments (10)

aquynh avatar aquynh commented on May 22, 2024

Cool, can you have a fix for this issue?

from keystone.

ekse avatar ekse commented on May 22, 2024

I don't know much about ARM, this document seems to be saying that valid local llabel values are in the range 0-99. Can we get someone to confirm?

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/Caccjfff.html

from keystone.

ekse avatar ekse commented on May 22, 2024

The code in AsmParser.cpp is generic for all assembly formats. The tombstone values (special markers) in DenseMap are defined as ~0 and ~0 - 1 which I think will be different values depending if keystone is compiled as 32 or 64-bit.

I think the easiest way to fix this issue would be to set an arbitrary maximum value, say 100,000, for the local label. That should be plenty enough, ARM supports up to 99 for example. Thoughts?

from keystone.

aquynh avatar aquynh commented on May 22, 2024

No we should not limit the number of labels.

from keystone.

ekse avatar ekse commented on May 22, 2024

I'm not suggesting to limit the number of labels, I'm suggesting to limit the value of local labels. They work as an offset in the assembly code, see the following example.

http://stackoverflow.com/questions/32341112/arm-assembly-local-labels

from keystone.

aquynh avatar aquynh commented on May 22, 2024

it seems LLVM does not have any standard here, so yes lets set 99 as the limit for the label value. can you come up with a patch?

thanks.

from keystone.

ekse avatar ekse commented on May 22, 2024

Here is the pull request.

from keystone.

aquynh avatar aquynh commented on May 22, 2024

i just pushed a commit to fix this, can you confirm?

from keystone.

ekse avatar ekse commented on May 22, 2024

Unfortunately this breaks numeric local label:

When assembling with a previous build

~/g/k/build3 (master) $ kstool arm "1:blt 1b"
1:blt 1b = [ fe ff ff ba ]

When assembling with the current build

~/g/k/build3 (master) $ kstool arm "1:blt 1b"
ERROR: failed on ks_asm() with count = 0, error = 'Invalid label (KS_ERR_ASM_LABEL_INVALID)' (code = 160)

The problem is with the condition if (LocalLabelVal >= Instances.size(). Instances.size() returns the number of elements currently in the DenseMap, MCContext::NextInstance() and MCContext::GetInstance() are used to add new entries in the map (see the comments in MCContext.h). The out-of-bounds access Instances[LocalLabelVal] is handled via operator overloading. If the condition is changed to if (LocalLabelVal >= 100 for example the example works as expected.

from keystone.

aquynh avatar aquynh commented on May 22, 2024

ok, let me make another fix. can you send a PR for this new testcase so we will not break that in the future?

from keystone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.