[lld] r234925 - [Mips] Write _DYNAMIC symbol on MIPS targets
Simon Atanasyan
simon at atanasyan.com
Tue Apr 14 11:53:03 PDT 2015
Author: atanasyan
Date: Tue Apr 14 13:53:03 2015
New Revision: 234925
URL: http://llvm.org/viewvc/llvm-project?rev=234925&view=rev
Log:
[Mips] Write _DYNAMIC symbol on MIPS targets
Added:
lld/trunk/test/elf/Mips/dynamic-sym.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h?rev=234925&r1=234924&r2=234925&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.h Tue Apr 14 13:53:03 2015
@@ -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;
}
Added: lld/trunk/test/elf/Mips/dynamic-sym.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/dynamic-sym.test?rev=234925&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/dynamic-sym.test (added)
+++ lld/trunk/test/elf/Mips/dynamic-sym.test Tue Apr 14 13:53:03 2015
@@ -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
More information about the llvm-commits
mailing list