<div dir="ltr">Hi Simon,<div><br></div><div>LGTM, thanks!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 6, 2015 at 10:48 AM, Simon Atanasyan <span dir="ltr"><<a href="mailto:simon@atanasyan.com" target="_blank">simon@atanasyan.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi rafaelauler,<br>
<br>
This patch is a follow-up to the rL232409 and allows define symbols in a linker script in case of linking shared library.<br>
<br>
REPOSITORY<br>
rL LLVM<br>
<br>
<a href="http://reviews.llvm.org/D8840" target="_blank">http://reviews.llvm.org/D8840</a><br>
<br>
Files:<br>
lib/ReaderWriter/ELF/DynamicLibraryWriter.h<br>
test/elf/linkerscript/Inputs/simple-pic.o.yaml<br>
test/elf/linkerscript/symbol-definition-so.test<br>
<br>
Index: lib/ReaderWriter/ELF/DynamicLibraryWriter.h<br>
===================================================================<br>
--- lib/ReaderWriter/ELF/DynamicLibraryWriter.h<br>
+++ lib/ReaderWriter/ELF/DynamicLibraryWriter.h<br>
@@ -60,6 +60,7 @@<br>
}<br>
<br>
template <class ELFT> void DynamicLibraryWriter<ELFT>::addDefaultAtoms() {<br>
+ OutputELFWriter<ELFT>::addDefaultAtoms();<br>
_runtimeFile->addAbsoluteAtom("_end");<br>
}<br>
<br>
@@ -76,6 +77,7 @@<br>
<br>
template <class ELFT><br>
void DynamicLibraryWriter<ELFT>::finalizeDefaultAtomValues() {<br>
+ OutputELFWriter<ELFT>::finalizeDefaultAtomValues();<br>
lld::AtomLayout *underScoreEndAtom = this->_layout.findAbsoluteAtom("_end");<br>
assert(underScoreEndAtom);<br>
<br>
Index: test/elf/linkerscript/Inputs/simple-pic.o.yaml<br>
===================================================================<br>
--- /dev/null<br>
+++ test/elf/linkerscript/Inputs/simple-pic.o.yaml<br>
@@ -0,0 +1,32 @@<br>
+FileHeader:<br>
+ Class: ELFCLASS64<br>
+ Data: ELFDATA2LSB<br>
+ Type: ET_REL<br>
+ Machine: EM_X86_64<br>
+<br>
+Sections:<br>
+ - Name: .text<br>
+ Type: SHT_PROGBITS<br>
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]<br>
+ AddressAlign: 4<br>
+ Size: 16<br>
+<br>
+ - Name: .data<br>
+ Type: SHT_PROGBITS<br>
+ Flags: [ SHF_WRITE, SHF_ALLOC ]<br>
+ AddressAlign: 4<br>
+ Size: 16<br>
+<br>
+Symbols:<br>
+ Local:<br>
+ - Name: .data<br>
+ Type: STT_SECTION<br>
+ Section: .data<br>
+ - Name: .text<br>
+ Type: STT_SECTION<br>
+ Section: .text<br>
+ Global:<br>
+ - Name: foo<br>
+ Type: STT_FUNC<br>
+ Section: .text<br>
+ Size: 16<br>
Index: test/elf/linkerscript/symbol-definition-so.test<br>
===================================================================<br>
--- /dev/null<br>
+++ test/elf/linkerscript/symbol-definition-so.test<br>
@@ -0,0 +1,32 @@<br>
+/*<br>
+We test whether we can define symbols in a linker script and have them exported<br>
+to the output file symbol table. This test is the same as symbol-definition.test<br>
+but make checking in case of shared library linking.<br>
+<br>
+We use the following linker script for this test:<br>
+*/<br>
+<br>
+SECTIONS<br>
+{<br>
+ .text : { *(.text) }<br>
+ MYSTRING = .;<br>
+ .data : { *(.data) }<br>
+}<br>
+<br>
+/*<br>
+RUN: yaml2obj -format=elf %p/Inputs/simple-pic.o.yaml -o=%t.o<br>
+<br>
+RUN: lld -flavor gnu -target x86_64 -shared -T %s %t.o -o %t.so<br>
+RUN: llvm-readobj -s -symbols %t.so | FileCheck -check-prefix CHECKSYMS %s<br>
+<br>
+CHECKSYMS: Name: .data<br>
+CHECKSYMS-NEXT: Type: SHT_PROGBITS<br>
+CHECKSYMS-NEXT: Flags [<br>
+CHECKSYMS-NEXT: SHF_ALLOC<br>
+CHECKSYMS-NEXT: SHF_WRITE<br>
+CHECKSYMS-NEXT: ]<br>
+CHECKSYMS-NEXT: Address: 0x401060<br>
+<br>
+CHECKSYMS: Name: MYSTRING<br>
+CHECKSYMS-NEXT: Value: 0x401060<br>
+*/<br>
<br>
EMAIL PREFERENCES<br>
<a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</blockquote></div><br></div>