diff options
| author | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-01 09:14:21 +0000 |
|---|---|---|
| committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2013-02-01 09:14:21 +0000 |
| commit | 08b49bf27eeca43fd6a07ff949f96979890494dd (patch) | |
| tree | 5ff2486637931a494745dfa60fa0f73c814f995d | |
| parent | 9eaab4be04986319ae8c75c933fbe7de9ab48d68 (diff) | |
| download | bcm5719-llvm-08b49bf27eeca43fd6a07ff949f96979890494dd.tar.gz bcm5719-llvm-08b49bf27eeca43fd6a07ff949f96979890494dd.zip | |
[ELF][x86-64] Fix ifunc and add test.
In an previous commit I managed to completely disable the IRELATIVE relocation
writing code. I also used the wrong addend for the static relocation. Fix both
these issues and add a test. This test is quite brittle because there's no way
to do arithmetic on variables in FileCheck.
llvm-svn: 174161
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/DefaultLayout.h | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp | 2 | ||||
| -rw-r--r-- | lld/test/elf/ifunc.test | 11 |
3 files changed, 13 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/ELF/DefaultLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h index 76e55e2c9d8..9358a79dc8c 100644 --- a/lld/lib/ReaderWriter/ELF/DefaultLayout.h +++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h @@ -442,11 +442,11 @@ ErrorOr<const AtomLayout &> DefaultLayout<ELFT>::addAtom(const Atom *atom) { } else { section = _sectionMap[sectionKey]; } - return section->appendAtom(atom); // Add runtime relocations to the .rela section. for (const auto &reloc : *definedAtom) if (_targetInfo.isRuntimeRelocation(*definedAtom, *reloc)) getRelocationTable()->addRelocation(*definedAtom, *reloc); + return section->appendAtom(atom); } else if (const AbsoluteAtom *absoluteAtom = dyn_cast<AbsoluteAtom>(atom)) { // Absolute atoms are not part of any section, they are global for the whole // link diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp index 3a4dee7d3aa..ead127773c3 100644 --- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp +++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp @@ -157,7 +157,7 @@ class GOTPLTPass LLVM_FINAL : public Pass { auto ga = new (_file._alloc) GOTAtom(_file, ".got.plt"); ga->addReference(R_X86_64_IRELATIVE, 0, &da, 0); auto pa = new (_file._alloc) PLTAtom(_file, ".plt"); - pa->addReference(R_X86_64_PC32, 2, ga, 0); + pa->addReference(R_X86_64_PC32, 2, ga, -4); #ifndef NDEBUG ga->_name = "__got_ifunc_"; ga->_name += da.name(); diff --git a/lld/test/elf/ifunc.test b/lld/test/elf/ifunc.test index 595a8802a93..e1a5d7bb5f9 100644 --- a/lld/test/elf/ifunc.test +++ b/lld/test/elf/ifunc.test @@ -1,8 +1,13 @@ RUN: lld -core -target x86_64-linux -emit-yaml -output=- %p/Inputs/ifunc.x86-64 \ RUN: | FileCheck %s + RUN: lld -core -target x86_64-linux -emit-yaml -output=- %p/Inputs/ifunc.x86-64 \ RUN: %p/Inputs/ifunc.cpp.x86-64 | FileCheck %s --check-prefix=PLT +RUN: lld -core -target x86_64-linux -output=%t %p/Inputs/ifunc.x86-64 \ +RUN: %p/Inputs/ifunc.cpp.x86-64 && llvm-objdump -d %t| FileCheck %s \ +RUN: --check-prefix=BIN + CHECK: name: hey CHECK: scope: global CHECK: type: resolver @@ -25,3 +30,9 @@ PLT: name: [[PLTNAME]] PLT: type: stub PLT: references PLT: kind: R_X86_64_PC32 + +// This is a horribly brittle test. We need a way to do arithmetic on captured +// variables. +BIN: 400136: ff 25 c4 0e 00 00 jumpq *3780(%rip) +BIN: .got.plt: +BIN-NEXT: 401000 00000000 00000000 |

