[PATCH] Add default parameter to MCSymbol accessors to control IsUsed
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 09:31:47 PDT 2015
Hi Rafael,
Sorry for the delay on this.
> I think that dates from the early days of MC. My understanding is that
> it was added just as a safety so that we have to reason about code
> like
>
> foo = bar
> .long foo
> foo = zed
> .long foo
>
> Should that produce two relocations with bar, two with foo or one each?
Here is what GAS does:
SYMBOL TABLE:
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 *UND* 00000000 bar
00000000 *UND* 00000000 zed
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_386_32 bar
00000004 R_386_32 zed
Here is a different test that initially triggered this issue:
> foo = bar
> .long foo
> foo = bar
> .long foo
And here is GAS's output:
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000000 R_386_32 bar
00000004 R_386_32 bar
With the patch I suggested, both of these examples just work with llvm-mc. Here's what the relocation table looks like on Darwin for comparison:
Relocation information (__TEXT,__text) 2 entries
address pcrel length extern type scattered symbolnum/value
00000004 0 2 1 0 0 1
00000000 0 2 1 0 0 1
This looks sane to me. I've updated the patch to get rid of the "invalid reassignment to non-absolute variable" error and fixed the test cases. Could you review it for any issues?
thanks
vedant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MCSymbol-patch1-NFC.patch
Type: application/octet-stream
Size: 2856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150813/e404f6ac/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MCSymbol-patch2.patch
Type: application/octet-stream
Size: 3340 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150813/e404f6ac/attachment-0001.obj>
More information about the llvm-commits
mailing list