forked from OSchip/llvm-project
[Mips] Allocate local GOT entry for a global symbol defined in an
executable file. llvm-svn: 199517
This commit is contained in:
parent
362bdc125e
commit
9ab3b8db84
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue