[lld] r373168 - [MC] Emit unused undefined symbol even if its binding is not set

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 29 08:26:13 PDT 2019


Author: maskray
Date: Sun Sep 29 08:26:12 2019
New Revision: 373168

URL: http://llvm.org/viewvc/llvm-project?rev=373168&view=rev
Log:
[MC] Emit unused undefined symbol even if its binding is not set

For the following two cases, we currently suppress the symbols. This
patch emits them (compatible with GNU as).

* `test2_a = undef`: if `undef` is otherwise unused.
* `.hidden hidden`: if `hidden` is unused. This is the main point of the
  patch, because omitting the symbol would cause a linker semantic
  difference.

It causes a behavior change that is not compatible with GNU as:

.weakref foo1, bar1

When neither foo1 nor bar1 is used, we now emit bar1, which is arguably
more consistent.

Another change is that we will emit .TOC. for .TOC. at tocbase .  For this
directive, suppressing .TOC. can be seen as a size optimization, but we
choose to drop it for simplicity and consistency.

Modified:
    lld/trunk/test/ELF/ppc64-abs64-dyn.s
    lld/trunk/test/ELF/ppc64-relocs.s

Modified: lld/trunk/test/ELF/ppc64-abs64-dyn.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ppc64-abs64-dyn.s?rev=373168&r1=373167&r2=373168&view=diff
==============================================================================
--- lld/trunk/test/ELF/ppc64-abs64-dyn.s (original)
+++ lld/trunk/test/ELF/ppc64-abs64-dyn.s Sun Sep 29 08:26:12 2019
@@ -12,10 +12,10 @@
 
 ## FIXME the addend for offset 0x20000 should be TOC base+0x8000+1, not 0x80001.
 # CHECK:      .rela.dyn {
-# CHECK-NEXT:   0x303B0 R_PPC64_RELATIVE - 0x8001
-# CHECK-NEXT:   0x303B8 R_PPC64_RELATIVE - 0x303B1
-# CHECK-NEXT:   0x303C0 R_PPC64_ADDR64 external 0x1
-# CHECK-NEXT:   0x303C8 R_PPC64_ADDR64 global 0x1
+# CHECK-NEXT:   0x303B8 R_PPC64_RELATIVE - 0x8001
+# CHECK-NEXT:   0x303C0 R_PPC64_RELATIVE - 0x303B9
+# CHECK-NEXT:   0x303C8 R_PPC64_ADDR64 external 0x1
+# CHECK-NEXT:   0x303D0 R_PPC64_ADDR64 global 0x1
 # CHECK-NEXT: }
 
 .data

Modified: lld/trunk/test/ELF/ppc64-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/ppc64-relocs.s?rev=373168&r1=373167&r2=373168&view=diff
==============================================================================
--- lld/trunk/test/ELF/ppc64-relocs.s (original)
+++ lld/trunk/test/ELF/ppc64-relocs.s Sun Sep 29 08:26:12 2019
@@ -26,13 +26,13 @@ _start:
   ld 1, .L1 at toc@l(2)
 
 # CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_LO_DS:
-# CHECK: ld 1, -32768(2)
+# CHECK: ld 1, -32760(2)
 
 .section .R_PPC64_TOC16_LO,"ax", at progbits
   addi  1, 2, .L1 at toc@l
 
 # CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_LO:
-# CHECK: addi 1, 2, -32768
+# CHECK: addi 1, 2, -32760
 
 .section .R_PPC64_TOC16_HI,"ax", at progbits
   addis 1, 2, .L1 at toc@h




More information about the llvm-commits mailing list