[lld] r199517 - [Mips] Allocate local GOT entry for a global symbol defined in an
Simon Atanasyan
simon at atanasyan.com
Fri Jan 17 13:18:46 PST 2014
Author: atanasyan
Date: Fri Jan 17 15:18:45 2014
New Revision: 199517
URL: http://llvm.org/viewvc/llvm-project?rev=199517&view=rev
Log:
[Mips] Allocate local GOT entry for a global symbol defined in an
executable file.
Added:
lld/trunk/test/elf/Mips/exe-got.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=199517&r1=199516&r2=199517&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Fri Jan 17 15:18:45 2014
@@ -114,7 +114,8 @@ public:
class RelocationPass : public Pass {
public:
- RelocationPass(MipsLinkingContext &context) : _file(context) {
+ RelocationPass(MipsLinkingContext &context)
+ : _context(context), _file(context) {
_localGotVector.push_back(new (_file._alloc) GOT0Atom(_file));
_localGotVector.push_back(new (_file._alloc) GOTModulePointerAtom(_file));
}
@@ -157,6 +158,9 @@ public:
}
private:
+ /// \brief Reference to the linking context.
+ const MipsLinkingContext &_context;
+
/// \brief Owner of all the Atoms created by this pass.
RelocationPassFile _file;
@@ -229,6 +233,10 @@ private:
scope == Atom::scopeLinkageUnit)
return true;
+ // External symbol defined in an executable file requires a local GOT entry.
+ if (_context.getOutputELFType() == llvm::ELF::ET_EXEC)
+ return true;
+
return false;
}
Added: lld/trunk/test/elf/Mips/exe-got.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/exe-got.test?rev=199517&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/exe-got.test (added)
+++ lld/trunk/test/elf/Mips/exe-got.test Fri Jan 17 15:18:45 2014
@@ -0,0 +1,60 @@
+# Check that external symbol defined in the executable file
+# and referenced by R_MIPS_CALL16 relocation has a corresponded
+# entry in the local GOT section.
+#
+# Build shared library
+# RUN: llvm-mc -triple=mipsel -filetype=obj -relocation-model=pic \
+# RUN: -o=%t1 %p/Inputs/ext.s
+# RUN: lld -flavor gnu -target mipsel -shared -o %t2 %t1
+
+# Build executable
+# RUN: llvm-mc -triple=mipsel -filetype=obj -o=%t3 %s
+# RUN: lld -flavor gnu -target mipsel -e glob \
+# RUN: --output-filetype=yaml -o %t4 %t3 %t2
+# RUN: FileCheck -check-prefix=GOT %s < %t4
+
+# GOT header
+# GOT: - type: got
+# GOT: content: [ 00, 00, 00, 00 ]
+# GOT: alignment: 2^2
+# GOT: section-choice: custom-required
+# GOT: section-name: .got
+# GOT: permissions: rw-
+# GOT: - type: got
+# GOT: content: [ 00, 00, 00, 80 ]
+# GOT: alignment: 2^2
+# GOT: section-choice: custom-required
+# GOT: section-name: .got
+# GOT: permissions: rw-
+# Local GOT entry for 'glob' symbol
+# GOT: - ref-name: L000
+# GOT: type: got
+# GOT: content: [ 00, 00, 00, 00 ]
+# GOT: alignment: 2^2
+# GOT: section-choice: custom-required
+# GOT: section-name: .got
+# GOT: permissions: rw-
+# GOT: references:
+# GOT: - kind: R_MIPS_32
+# GOT: offset: 0
+# GOT: target: glob
+# Global GOT entry for 'ext1' symbol
+# GOT: - ref-name: L001
+# GOT: type: got
+# GOT: content: [ 00, 00, 00, 00 ]
+# GOT: alignment: 2^2
+# GOT: section-choice: custom-required
+# GOT: section-name: .got
+# GOT: permissions: rw-
+# GOT: references:
+# GOT: - kind: LLD_R_MIPS_GLOBAL_GOT
+# GOT: offset: 0
+# GOT: target: ext1
+
+ .abicalls
+ .global glob
+ .ent glob
+glob:
+ lw $4,%call16(glob)($28)
+ lw $4,%call16(ext1)($28)
+ .end glob
More information about the llvm-commits
mailing list