Add a variant of .definelabel that avoids getting incremented when used from an object file, even when defined in THUMB mode #248
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The situation this is trying to help with is basically this:
Assume this is
test.c
and it gets compiled with-mthumb
:And then this is
test.asm
:It assembles without complaint, but it's actually broken because the code inside the object file will actually try to read from 0x03003F21. This is because
gLinkStatus
was.definelabel
ed in THUMB mode, and even though it's not a function, it still gets incremented when used by object files.You can fix it by doing
But that's easy to forget and there's no error or warning if you do so.
This implements (among other things) a
.defineobj
/.defineobject
that works the way.definelabel
works in ARM mode, even if you're actually in THUMB mode. So you could just do.defineobj gLinkStatus, 0x03003F20
and it works.Actually, this implements a few more variants of
.definelabel
:.definefunc
,.definearmfunc
, and.definethumbfunc
(the first is an alias of.definelabel
and the other two work the way you would probably expect from the names). I'm mostly interested in.defineobj
, but they were easy to throw in.While this works, I'm not really sure if this is really a reasonable way to do it. And even if it is generally sound,
ArmInfoMode
is a terrible name and it definitely doesn't belong inCommands/CAssemblerLabel.h
. But I couldn't figure out a better name or place for it.If you have any suggestions or concerns, please let me know.