[Mips] Write _DYNAMIC symbol on MIPS targets

llvm-svn: 234925
This commit is contained in:
Simon Atanasyan 2015-04-14 18:53:03 +00:00
parent dd6f1aaa73
commit 23025c812e
2 changed files with 49 additions and 0 deletions

View File

@ -16,6 +16,13 @@ namespace elf {
template <class ELFT> class MipsTargetLayout;
class MipsDynamicAtom : public DynamicAtom {
public:
MipsDynamicAtom(const File &f) : DynamicAtom(f) {}
ContentPermissions permissions() const override { return permR__; }
};
template <typename ELFT> class MipsELFWriter {
public:
MipsELFWriter(MipsLinkingContext &ctx, MipsTargetLayout<ELFT> &targetLayout)
@ -54,6 +61,7 @@ public:
file->addAbsoluteAtom("_gp");
file->addAbsoluteAtom("_gp_disp");
file->addAbsoluteAtom("__gnu_local_gp");
file->addAtom(*new (file->allocator()) MipsDynamicAtom(*file));
}
return file;
}

View File

@ -0,0 +1,41 @@
# Check _DYNAMIC symbol's value
#
# RUN: yaml2obj -format=elf %s > %t.o
# RUN: lld -flavor gnu -target mipsel -shared -e T0 -o %t.so %t.o
# RUN: llvm-objdump -h -t %t.so | FileCheck -check-prefix=SHARED %s
# SHARED: Sections:
# SHARED: Idx Name Size Address Type
# SHARED: 5 .dynamic 00000068 00000000000000d4
# SHARED: SYMBOL TABLE:
# SHARED: 000000d4 g .dynamic 00000000 _DYNAMIC
# RUN: lld -flavor gnu -target mipsel -e main -e T0 -o %t.exe %t.o
# RUN: llvm-objdump -h -t %t.exe | FileCheck -check-prefix=EXE %s
# EXE: Sections:
# EXE: Idx Name Size Address Type
# EXE: 6 .dynamic 00000068 0000000000400114
# EXE: SYMBOL TABLE:
# EXE: 00400114 g .dynamic 00000000 _DYNAMIC
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [SHF_ALLOC, SHF_EXECINSTR]
AddressAlign: 0x10
Size: 0x04
Symbols:
Global:
- Name: T0
Section: .text