[llvm-bugs] [Bug 51047] New: lld produces an empty relocation if it did target a discarded section

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jul 10 07:41:07 PDT 2021


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

            Bug ID: 51047
           Summary: lld produces an empty relocation if it did target a
                    discarded section
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: jan.kratochvil at redhat.com
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com

echo '__attribute__((__section__("discardme"))) char
x;__attribute__((__section__(".debug_info"))) char *xp = &x;'|clang -Wall -c -o
discard.o -x c -;echo 'SECTIONS { /DISCARD/ : { *(discardme) } }'
>discard.lds;ld.lld -r -m elf_x86_64 -T discard.lds -o discard2.o
discard.o;llvm-readelf -r discard2.o

Actual:
Relocation section '.rela.debug_info' at offset 0x48 contains 1 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  0000000000000001 R_X86_64_64                       0

Expected either - as ld.bfd creates:
Relocation section '.rela.debug_info' at offset 0x140 contains 1 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000000000  0000000000000000 R_X86_64_NONE                     0

Expected or (preferred, this is what ld.bfd creates in real world cases):
There are no relocations in this file.

FAIL: lld-12.0.0-1.fc34.x86_64
FAIL: LLD 13.0.0 8cf7ddbdd4e5af966a369e170c73250f2e3920e7 = 2021-07-10
PASS: ld.bfd = binutils-2.35.1-41.fc34.x86_64
FAIL: ld.gold = binutils-gold-2.35.1-41.fc34.x86_64

-- 
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/20210710/378f0b9b/attachment.html>


More information about the llvm-bugs mailing list