[llvm-bugs] [Bug 41355] New: Relocation records printed in the wrong format

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 2 16:37:55 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41355

            Bug ID: 41355
           Summary: Relocation records printed in the wrong format
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llvm-objdump
          Assignee: unassignedbugs at nondot.org
          Reporter: rupprecht at google.com
                CC: llvm-bugs at lists.llvm.org

llvm-objdump (for ELF files at least) prints relocation records *in* a section,
however, it prints them as being "for" a section. This breaks GNU objdump
compatibility, and I think it may be slightly wrong.

Take for example the test file generated by
llvm/test/tools/llvm-objdump/relocations-elf.test:
$ llvm-readelf -r test/tools/llvm-objdump/Output/relocations-elf.test.tmp

Relocation section '.rel.text' at offset 0x208 contains 3 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name
0000000000000001  000000030000000a R_X86_64_32            0000000000000000
glob1
0000000000000001  000000040000000b R_X86_64_32S           0000000000000000
glob2
0000000000000002  0000000100000001 R_X86_64_64            0000000000000000 loc1

Relocation section '.rela.text' at offset 0x238 contains 3 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000001  000000030000000a R_X86_64_32            0000000000000000
glob1 + 1
0000000000000001  000000040000000b R_X86_64_32S           0000000000000000
glob2 + 2
0000000000000002  0000000100000001 R_X86_64_64            0000000000000000 loc1
+ 3

The file contains relocations for .text in both .rel.text and .rela.text. (GNU
readelf matches this output, modulo minor syntax tweaks)

llvm-objdump lists them in a similar way:
$ llvm-objdump -r test/tools/llvm-objdump/Output/relocations-elf.test.tmp

test/tools/llvm-objdump/Output/relocations-elf.test.tmp:        file format
ELF64-x86-64

RELOCATION RECORDS FOR [.rel.text]:
0000000000000001 R_X86_64_32 glob1
0000000000000001 R_X86_64_32S glob2
0000000000000002 R_X86_64_64 loc1

RELOCATION RECORDS FOR [.rela.text]:
0000000000000001 R_X86_64_32 glob1+1
0000000000000001 R_X86_64_32S glob2+2
0000000000000002 R_X86_64_64 loc1+3

GNU objdump puts them all together:
$ objdump -r test/tools/llvm-objdump/Output/relocations-elf.test.tmp

test/tools/llvm-objdump/Output/relocations-elf.test.tmp:     file format
elf64-x86-64

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE
0000000000000001 R_X86_64_32       glob1
0000000000000001 R_X86_64_32S      glob2
0000000000000002 R_X86_64_64       loc1
0000000000000001 R_X86_64_32       glob1+0x0000000000000001
0000000000000001 R_X86_64_32S      glob2+0x0000000000000002
0000000000000002 R_X86_64_64       loc1+0x0000000000000003

I think we should either:
* Put all the relocations for a given section together, and list the section
name as what it's a relocation for (i.e. match GNU)
* Changing the wording to "in" instead of "for", e.g. "relocation records in
[.rel.text]"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190402/2e0db7ae/attachment.html>


More information about the llvm-bugs mailing list