[lld] r243211 - [Mips] Define _DYNAMIC_LINKING symbol if output is a is dynamically linked executable file
Simon Atanasyan
simon at atanasyan.com
Sat Jul 25 03:18:53 PDT 2015
Author: atanasyan
Date: Sat Jul 25 05:18:52 2015
New Revision: 243211
URL: http://llvm.org/viewvc/llvm-project?rev=243211&view=rev
Log:
[Mips] Define _DYNAMIC_LINKING symbol if output is a is dynamically linked executable file
Added:
lld/trunk/test/elf/Mips/dynamic-linking.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp?rev=243211&r1=243210&r2=243211&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp Sat Jul 25 05:18:52 2015
@@ -56,6 +56,9 @@ void MipsELFWriter<ELFT>::finalizeMipsRu
setAtomValue("_gp", gp);
setAtomValue("_gp_disp", gp);
setAtomValue("__gnu_local_gp", gp);
+
+ if (_ctx.isDynamic() && _ctx.getOutputELFType() == ET_EXEC)
+ setAtomValue("_DYNAMIC_LINKING", 1);
}
template <class ELFT>
@@ -64,8 +67,11 @@ std::unique_ptr<RuntimeFile<ELFT>> MipsE
file->addAbsoluteAtom("_gp");
file->addAbsoluteAtom("_gp_disp");
file->addAbsoluteAtom("__gnu_local_gp");
- if (_ctx.isDynamic())
+ if (_ctx.isDynamic()) {
file->addAtom(*new (file->allocator()) MipsDynamicAtom(*file));
+ if (_ctx.getOutputELFType() == ET_EXEC)
+ file->addAbsoluteAtom("_DYNAMIC_LINKING");
+ }
return file;
}
Added: lld/trunk/test/elf/Mips/dynamic-linking.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/dynamic-linking.test?rev=243211&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/dynamic-linking.test (added)
+++ lld/trunk/test/elf/Mips/dynamic-linking.test Sat Jul 25 05:18:52 2015
@@ -0,0 +1,22 @@
+# REQUIRES: mips
+
+# Check _DYNAMIC_LINKING symbol definition.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
+# RUN: lld -flavor gnu -target mips %t.o -o %t.exe
+# RUN: llvm-nm %t.exe | FileCheck -check-prefix=EXE-DYN %s
+
+# EXE-DYN: 00000001 A _DYNAMIC_LINKING
+
+# RUN: lld -flavor gnu -target mips -static %t.o -o %t.exe
+# RUN: llvm-nm -just-symbol-name %t.exe | FileCheck -check-prefix=EXE-STATIC %s
+
+# EXE-STATIC-NOT: _DYNAMIC_LINKING
+
+# RUN: lld -flavor gnu -target mips -shared %t.o -o %t.so
+# RUN: llvm-nm -just-symbol-name %t.so | FileCheck -check-prefix=DYNLIB %s
+
+# DYNLIB-NOT: _DYNAMIC_LINKING
+
+ .globl __start;
+__start:
More information about the llvm-commits
mailing list