[lld] c4c68b6 - [ELF] Write R_AARCH64_IRELATIVE addends with -z rel

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 30 01:20:04 PDT 2022


Author: Fangrui Song
Date: 2022-07-30T01:19:59-07:00
New Revision: c4c68b676ee0d2036511db8b64844d03c1ba0b6d

URL: https://github.com/llvm/llvm-project/commit/c4c68b676ee0d2036511db8b64844d03c1ba0b6d
DIFF: https://github.com/llvm/llvm-project/commit/c4c68b676ee0d2036511db8b64844d03c1ba0b6d.diff

LOG: [ELF] Write R_AARCH64_IRELATIVE addends with -z rel

Added: 
    

Modified: 
    lld/ELF/Arch/AArch64.cpp
    lld/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Arch/AArch64.cpp b/lld/ELF/Arch/AArch64.cpp
index 1949169d6447b..d3b337a996fd5 100644
--- a/lld/ELF/Arch/AArch64.cpp
+++ b/lld/ELF/Arch/AArch64.cpp
@@ -35,6 +35,7 @@ class AArch64 : public TargetInfo {
   RelType getDynRel(RelType type) const override;
   int64_t getImplicitAddend(const uint8_t *buf, RelType type) const override;
   void writeGotPlt(uint8_t *buf, const Symbol &s) const override;
+  void writeIgotPlt(uint8_t *buf, const Symbol &s) const override;
   void writePltHeader(uint8_t *buf) const override;
   void writePlt(uint8_t *buf, const Symbol &sym,
                 uint64_t pltEntryAddr) const override;
@@ -214,6 +215,11 @@ void AArch64::writeGotPlt(uint8_t *buf, const Symbol &) const {
   write64(buf, in.plt->getVA());
 }
 
+void AArch64::writeIgotPlt(uint8_t *buf, const Symbol &s) const {
+  if (config->writeAddends)
+    write64(buf, s.getVA());
+}
+
 void AArch64::writePltHeader(uint8_t *buf) const {
   const uint8_t pltData[] = {
       0xf0, 0x7b, 0xbf, 0xa9, // stp    x16, x30, [sp,#-16]!

diff  --git a/lld/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s b/lld/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s
index 930709badcd11..048d996fa1b4e 100644
--- a/lld/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s
+++ b/lld/test/ELF/aarch64-gnu-ifunc-nonpreemptable.s
@@ -6,8 +6,10 @@
 # RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=PDE-RELOC
 
 # RUN: ld.lld -pie --no-relax %t.o -o %t
+# RUN: ld.lld -pie --no-relax --apply-dynamic-relocs %t.o -o %t.apply
 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PIE
-# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=PIE-RELOC
+# RUN: llvm-readobj -r -x .got.plt %t | FileCheck %s --check-prefixes=PIE-RELOC,NO-APPLY
+# RUN: llvm-readobj -r -x .got.plt %t.apply | FileCheck %s --check-prefixes=PIE-RELOC,APPLY
 
 ## When compiling with -fno-PIE or -fPIE, if the ifunc is in the same
 ## translation unit as the address taker, the compiler knows that ifunc is not
@@ -70,3 +72,7 @@ main:
 # PIE-RELOC:      .rela.dyn {
 # PIE-RELOC-NEXT:   0x30380 R_AARCH64_IRELATIVE - 0x10260
 # PIE-RELOC-NEXT: }
+# PIE-RELOC:      Hex dump of section '.got.plt':
+# NO-APPLY:       0x00030380 00000000 00000000
+# APPLY:          0x00030380 60020100 00000000
+# PIE-RELOC-EMPTY:


        


More information about the llvm-commits mailing list