<div dir="ltr">:)</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 5:35 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">But your code puts section *headers* after the string table, no? If the end of the string table is not aligned, looks like section headers will not be aligned.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 5:33 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">The string table itself has an alignment of 1, so it works. </p>
<p dir="ltr">The existing alignment code for regular sections is correct but a bit more conservative than necessary I think. </p><div><div>
<div class="gmail_quote">On Aug 11, 2015 8:29 PM, "Rui Ueyama" <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Does StringTableBuilder::finalize take care of alignment? Are section headers aligned with this patch?</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 5:00 PM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Tue Aug 11 19:00:24 2015<br>
New Revision: 244702<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244702&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244702&view=rev</a><br>
Log:<br>
ELF: Create a string table.<br>
<br>
For now only the sections are in it, but it already makes the output easier<br>
to read and test.<br>
<br>
Added:<br>
lld/trunk/test/elf2/string-table.s<br>
Modified:<br>
lld/trunk/ELF/CMakeLists.txt<br>
lld/trunk/ELF/Writer.cpp<br>
lld/trunk/test/elf2/basic.s<br>
lld/trunk/test/elf2/basic32.s<br>
lld/trunk/test/elf2/basic32be.s<br>
lld/trunk/test/elf2/basic64be.s<br>
<br>
Modified: lld/trunk/ELF/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/CMakeLists.txt?rev=244702&r1=244701&r2=244702&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/CMakeLists.txt?rev=244702&r1=244701&r2=244702&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/CMakeLists.txt (original)<br>
+++ lld/trunk/ELF/CMakeLists.txt Tue Aug 11 19:00:24 2015<br>
@@ -15,6 +15,7 @@ add_llvm_library(lldELF2<br>
LINK_COMPONENTS<br>
Object<br>
Option<br>
+ MC<br>
Support<br>
)<br>
<br>
<br>
Modified: lld/trunk/ELF/Writer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=244702&r1=244701&r2=244702&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=244702&r1=244701&r2=244702&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Writer.cpp (original)<br>
+++ lld/trunk/ELF/Writer.cpp Tue Aug 11 19:00:24 2015<br>
@@ -12,7 +12,9 @@<br>
#include "Error.h"<br>
#include "SymbolTable.h"<br>
#include "Writer.h"<br>
+<br>
#include "llvm/ADT/DenseMap.h"<br>
+#include "llvm/MC/StringTableBuilder.h"<br>
#include "llvm/Support/FileOutputBuffer.h"<br>
<br>
using namespace llvm;<br>
@@ -41,6 +43,8 @@ public:<br>
void addSectionChunk(SectionChunk<ELFT> *C);<br>
std::vector<Chunk *> &getChunks() { return Chunks; }<br>
void writeHeaderTo(Elf_Shdr *SHdr);<br>
+ StringRef getName() { return Name; }<br>
+ void setNameOffset(uintX_t Offset) { Header.sh_name = Offset; }<br>
<br>
// Returns the size of the section in the output file.<br>
uintX_t getSize() { return Header.sh_size; }<br>
@@ -73,6 +77,10 @@ private:<br>
uintX_t FileSize;<br>
uintX_t SizeOfHeaders;<br>
uintX_t SectionHeaderOff;<br>
+ uintX_t StringTableOff;<br>
+ unsigned StringTableIndex;<br>
+ StringTableBuilder StrTabBuilder;<br>
+ unsigned NumSections;<br>
<br>
std::vector<std::unique_ptr<Chunk>> Chunks;<br>
};<br>
@@ -160,10 +168,26 @@ template <class ELFT> void Writer<ELFT>:<br>
Sec->setFileOffset(FileOff);<br>
VA += RoundUpToAlignment(Sec->getSize(), PageSize);<br>
FileOff += RoundUpToAlignment(Sec->getSize(), 8);<br>
+ StrTabBuilder.add(Sec->getName());<br>
}<br>
+<br>
+ // Regular sections.<br>
+ NumSections = OutputSections.size();<br>
+<br>
+ // First dummy section.<br>
+ NumSections++;<br>
+<br>
+ // String table.<br>
+ StrTabBuilder.add(".strtab");<br>
+ StringTableIndex = NumSections;<br>
+ StringTableOff = FileOff;<br>
+ StrTabBuilder.finalize(StringTableBuilder::ELF);<br>
+ FileOff += StrTabBuilder.data().size();<br>
+ NumSections++;<br>
+<br>
// Add space for section headers.<br>
SectionHeaderOff = FileOff;<br>
- FileOff += (OutputSections.size() + 1) * sizeof(Elf_Shdr_Impl<ELFT>);<br>
+ FileOff += NumSections * sizeof(Elf_Shdr_Impl<ELFT>);<br>
FileSize = SizeOfHeaders + RoundUpToAlignment(FileOff - SizeOfHeaders, 8);<br>
}<br>
<br>
@@ -192,8 +216,8 @@ template <class ELFT> void Writer<ELFT>:<br>
EHdr->e_phentsize = sizeof(Elf_Phdr_Impl<ELFT>);<br>
EHdr->e_phnum = 1;<br>
EHdr->e_shentsize = sizeof(Elf_Shdr_Impl<ELFT>);<br>
- EHdr->e_shnum = OutputSections.size() + 1;<br>
- EHdr->e_shstrndx = 0;<br>
+ EHdr->e_shnum = NumSections;<br>
+ EHdr->e_shstrndx = StringTableIndex;<br>
<br>
auto PHdrs = reinterpret_cast<Elf_Phdr_Impl<ELFT> *>(Buf + EHdr->e_phoff);<br>
PHdrs->p_type = PT_LOAD;<br>
@@ -208,8 +232,22 @@ template <class ELFT> void Writer<ELFT>:<br>
auto SHdrs = reinterpret_cast<Elf_Shdr_Impl<ELFT> *>(Buf + EHdr->e_shoff);<br>
// First entry is null.<br>
++SHdrs;<br>
- for (OutputSection<ELFT> *Sec : OutputSections)<br>
+ for (OutputSection<ELFT> *Sec : OutputSections) {<br>
+ Sec->setNameOffset(StrTabBuilder.getOffset(Sec->getName()));<br>
Sec->writeHeaderTo(SHdrs++);<br>
+ }<br>
+<br>
+ // String table.<br>
+ SHdrs->sh_name = StrTabBuilder.getOffset(".strtab");<br>
+ SHdrs->sh_type = SHT_STRTAB;<br>
+ SHdrs->sh_flags = 0;<br>
+ SHdrs->sh_addr = 0;<br>
+ SHdrs->sh_offset = StringTableOff;<br>
+ SHdrs->sh_size = StrTabBuilder.data().size();<br>
+ SHdrs->sh_link = 0;<br>
+ SHdrs->sh_info = 0;<br>
+ SHdrs->sh_addralign = 1;<br>
+ SHdrs->sh_entsize = 0;<br>
}<br>
<br>
template <class ELFT> void Writer<ELFT>::openFile(StringRef Path) {<br>
@@ -225,4 +263,8 @@ template <class ELFT> void Writer<ELFT>:<br>
for (Chunk *C : Sec->getChunks())<br>
C->writeTo(Buf);<br>
}<br>
+<br>
+ // String table.<br>
+ StringRef Data = StrTabBuilder.data();<br>
+ memcpy(Buf + StringTableOff, Data.data(), Data.size());<br>
}<br>
<br>
Modified: lld/trunk/test/elf2/basic.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=244702&r1=244701&r2=244702&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic.s?rev=244702&r1=244701&r2=244702&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic.s (original)<br>
+++ lld/trunk/test/elf2/basic.s Tue Aug 11 19:00:24 2015<br>
@@ -25,15 +25,15 @@ _start:<br>
# CHECK-NEXT: Version: 1<br>
# CHECK-NEXT: Entry: 0x401000<br>
# CHECK-NEXT: ProgramHeaderOffset: 0x40<br>
-# CHECK-NEXT: SectionHeaderOffset: 0x1010<br>
+# CHECK-NEXT: SectionHeaderOffset: 0x102A<br>
# CHECK-NEXT: Flags [ (0x0)<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: HeaderSize: 64<br>
# CHECK-NEXT: ProgramHeaderEntrySize: 56<br>
# CHECK-NEXT: ProgramHeaderCount: 1<br>
# CHECK-NEXT: SectionHeaderEntrySize: 64<br>
-# CHECK-NEXT: SectionHeaderCount: 4<br>
-# CHECK-NEXT: StringTableSectionIndex: 0<br>
+# CHECK-NEXT: SectionHeaderCount: 5<br>
+# CHECK-NEXT: StringTableSectionIndex: 4<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Sections [<br>
# CHECK-NEXT: Section {<br>
@@ -52,7 +52,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 1<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .text<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x6)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -68,7 +68,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 2<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .data<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -84,7 +84,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 3<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .bss<br>
# CHECK-NEXT: Type: SHT_NOBITS (0x8)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -98,6 +98,20 @@ _start:<br>
# CHECK-NEXT: AddressAlignment: 0<br>
# CHECK-NEXT: EntrySize: 0<br>
# CHECK-NEXT: }<br>
+# CHECK-NEXT: Section {<br>
+# CHECK-NEXT: Index: 4<br>
+# CHECK-NEXT: Name: .strtab (12)<br>
+# CHECK-NEXT: Type: SHT_STRTAB (0x3)<br>
+# CHECK-NEXT: Flags [ (0x0)<br>
+# CHECK-NEXT: ]<br>
+# CHECK-NEXT: Address: 0x0<br>
+# CHECK-NEXT: Offset: 0x1010<br>
+# CHECK-NEXT: Size: 26<br>
+# CHECK-NEXT: Link: 0<br>
+# CHECK-NEXT: Info: 0<br>
+# CHECK-NEXT: AddressAlignment: 1<br>
+# CHECK-NEXT: EntrySize: 0<br>
+# CHECK-NEXT: }<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: ProgramHeaders [<br>
# CHECK-NEXT: ProgramHeader {<br>
@@ -105,8 +119,8 @@ _start:<br>
# CHECK-NEXT: Offset: 0x0<br>
# CHECK-NEXT: VirtualAddress: 0x400000<br>
# CHECK-NEXT: PhysicalAddress: 0x400000<br>
-# CHECK-NEXT: FileSize: 4368<br>
-# CHECK-NEXT: MemSize: 4368<br>
+# CHECK-NEXT: FileSize: 4464<br>
+# CHECK-NEXT: MemSize: 4464<br>
# CHECK-NEXT: Flags [ (0x5)<br>
# CHECK-NEXT: PF_R (0x4)<br>
# CHECK-NEXT: PF_X (0x1)<br>
<br>
Modified: lld/trunk/test/elf2/basic32.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=244702&r1=244701&r2=244702&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32.s?rev=244702&r1=244701&r2=244702&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic32.s (original)<br>
+++ lld/trunk/test/elf2/basic32.s Tue Aug 11 19:00:24 2015<br>
@@ -25,15 +25,15 @@ _start:<br>
# CHECK-NEXT: Version: 1<br>
# CHECK-NEXT: Entry: 0x401000<br>
# CHECK-NEXT: ProgramHeaderOffset: 0x34<br>
-# CHECK-NEXT: SectionHeaderOffset: 0x1010<br>
+# CHECK-NEXT: SectionHeaderOffset: 0x102A<br>
# CHECK-NEXT: Flags [ (0x0)<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: HeaderSize: 52<br>
# CHECK-NEXT: ProgramHeaderEntrySize: 32<br>
# CHECK-NEXT: ProgramHeaderCount: 1<br>
# CHECK-NEXT: SectionHeaderEntrySize: 40<br>
-# CHECK-NEXT: SectionHeaderCount: 4<br>
-# CHECK-NEXT: StringTableSectionIndex: 0<br>
+# CHECK-NEXT: SectionHeaderCount: 5<br>
+# CHECK-NEXT: StringTableSectionIndex: 4<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Sections [<br>
# CHECK-NEXT: Section {<br>
@@ -52,7 +52,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 1<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .text<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x6)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -68,7 +68,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 2<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .data<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -84,7 +84,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 3<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .bss<br>
# CHECK-NEXT: Type: SHT_NOBITS (0x8)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -98,6 +98,20 @@ _start:<br>
# CHECK-NEXT: AddressAlignment: 0<br>
# CHECK-NEXT: EntrySize: 0<br>
# CHECK-NEXT: }<br>
+# CHECK-NEXT: Section {<br>
+# CHECK-NEXT: Index: 4<br>
+# CHECK-NEXT: Name: .strtab<br>
+# CHECK-NEXT: Type: SHT_STRTAB (0x3)<br>
+# CHECK-NEXT: Flags [ (0x0)<br>
+# CHECK-NEXT: ]<br>
+# CHECK-NEXT: Address: 0x0<br>
+# CHECK-NEXT: Offset: 0x1010<br>
+# CHECK-NEXT: Size: 26<br>
+# CHECK-NEXT: Link: 0<br>
+# CHECK-NEXT: Info: 0<br>
+# CHECK-NEXT: AddressAlignment: 1<br>
+# CHECK-NEXT: EntrySize: 0<br>
+# CHECK-NEXT: }<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: ProgramHeaders [<br>
# CHECK-NEXT: ProgramHeader {<br>
@@ -105,8 +119,8 @@ _start:<br>
# CHECK-NEXT: Offset: 0x0<br>
# CHECK-NEXT: VirtualAddress: 0x400000<br>
# CHECK-NEXT: PhysicalAddress: 0x400000<br>
-# CHECK-NEXT: FileSize: 4272<br>
-# CHECK-NEXT: MemSize: 4272<br>
+# CHECK-NEXT: FileSize: 4344<br>
+# CHECK-NEXT: MemSize: 4344<br>
# CHECK-NEXT: Flags [ (0x5)<br>
# CHECK-NEXT: PF_R (0x4)<br>
# CHECK-NEXT: PF_X (0x1)<br>
<br>
Modified: lld/trunk/test/elf2/basic32be.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32be.s?rev=244702&r1=244701&r2=244702&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic32be.s?rev=244702&r1=244701&r2=244702&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic32be.s (original)<br>
+++ lld/trunk/test/elf2/basic32be.s Tue Aug 11 19:00:24 2015<br>
@@ -25,15 +25,15 @@ _start:<br>
# CHECK-NEXT: Version: 1<br>
# CHECK-NEXT: Entry: 0x401000<br>
# CHECK-NEXT: ProgramHeaderOffset: 0x34<br>
-# CHECK-NEXT: SectionHeaderOffset: 0x1010<br>
+# CHECK-NEXT: SectionHeaderOffset: 0x102A<br>
# CHECK-NEXT: Flags [ (0x0)<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: HeaderSize: 52<br>
# CHECK-NEXT: ProgramHeaderEntrySize: 32<br>
# CHECK-NEXT: ProgramHeaderCount: 1<br>
# CHECK-NEXT: SectionHeaderEntrySize: 40<br>
-# CHECK-NEXT: SectionHeaderCount: 4<br>
-# CHECK-NEXT: StringTableSectionIndex: 0<br>
+# CHECK-NEXT: SectionHeaderCount: 5<br>
+# CHECK-NEXT: StringTableSectionIndex: 4<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Sections [<br>
# CHECK-NEXT: Section {<br>
@@ -52,7 +52,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 1<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .text<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x6)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -68,7 +68,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 2<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .data<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -84,7 +84,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 3<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .bss<br>
# CHECK-NEXT: Type: SHT_NOBITS (0x8)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -98,6 +98,20 @@ _start:<br>
# CHECK-NEXT: AddressAlignment: 0<br>
# CHECK-NEXT: EntrySize: 0<br>
# CHECK-NEXT: }<br>
+# CHECK-NEXT: Section {<br>
+# CHECK-NEXT: Index: 4<br>
+# CHECK-NEXT: Name: .strtab<br>
+# CHECK-NEXT: Type: SHT_STRTAB (0x3)<br>
+# CHECK-NEXT: Flags [ (0x0)<br>
+# CHECK-NEXT: ]<br>
+# CHECK-NEXT: Address: 0x0<br>
+# CHECK-NEXT: Offset: 0x1010<br>
+# CHECK-NEXT: Size: 26<br>
+# CHECK-NEXT: Link: 0<br>
+# CHECK-NEXT: Info: 0<br>
+# CHECK-NEXT: AddressAlignment: 1<br>
+# CHECK-NEXT: EntrySize: 0<br>
+# CHECK-NEXT: }<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: ProgramHeaders [<br>
# CHECK-NEXT: ProgramHeader {<br>
@@ -105,8 +119,8 @@ _start:<br>
# CHECK-NEXT: Offset: 0x0<br>
# CHECK-NEXT: VirtualAddress: 0x400000<br>
# CHECK-NEXT: PhysicalAddress: 0x400000<br>
-# CHECK-NEXT: FileSize: 4272<br>
-# CHECK-NEXT: MemSize: 4272<br>
+# CHECK-NEXT: FileSize: 4344<br>
+# CHECK-NEXT: MemSize: 4344<br>
# CHECK-NEXT: Flags [ (0x5)<br>
# CHECK-NEXT: PF_R (0x4)<br>
# CHECK-NEXT: PF_X (0x1)<br>
<br>
Modified: lld/trunk/test/elf2/basic64be.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=244702&r1=244701&r2=244702&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/basic64be.s?rev=244702&r1=244701&r2=244702&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/basic64be.s (original)<br>
+++ lld/trunk/test/elf2/basic64be.s Tue Aug 11 19:00:24 2015<br>
@@ -30,15 +30,15 @@ _start:<br>
# CHECK-NEXT: Version: 1<br>
# CHECK-NEXT: Entry: 0x401000<br>
# CHECK-NEXT: ProgramHeaderOffset: 0x40<br>
-# CHECK-NEXT: SectionHeaderOffset: 0x1028<br>
+# CHECK-NEXT: SectionHeaderOffset: 0x1047<br>
# CHECK-NEXT: Flags [ (0x0)<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: HeaderSize: 64<br>
# CHECK-NEXT: ProgramHeaderEntrySize: 56<br>
# CHECK-NEXT: ProgramHeaderCount: 1<br>
# CHECK-NEXT: SectionHeaderEntrySize: 64<br>
-# CHECK-NEXT: SectionHeaderCount: 5<br>
-# CHECK-NEXT: StringTableSectionIndex: 0<br>
+# CHECK-NEXT: SectionHeaderCount: 6<br>
+# CHECK-NEXT: StringTableSectionIndex: 5<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Sections [<br>
# CHECK-NEXT: Section {<br>
@@ -57,7 +57,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 1<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .text<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x6)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -73,7 +73,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 2<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .data<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -89,7 +89,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 3<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .bss<br>
# CHECK-NEXT: Type: SHT_NOBITS (0x8)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -105,7 +105,7 @@ _start:<br>
# CHECK-NEXT: }<br>
# CHECK-NEXT: Section {<br>
# CHECK-NEXT: Index: 4<br>
-# CHECK-NEXT: Name: (0)<br>
+# CHECK-NEXT: Name: .opd<br>
# CHECK-NEXT: Type: SHT_PROGBITS (0x1)<br>
# CHECK-NEXT: Flags [ (0x3)<br>
# CHECK-NEXT: SHF_ALLOC (0x2)<br>
@@ -119,6 +119,20 @@ _start:<br>
# CHECK-NEXT: AddressAlignment: 0<br>
# CHECK-NEXT: EntrySize: 0<br>
# CHECK-NEXT: }<br>
+# CHECK-NEXT: Section {<br>
+# CHECK-NEXT: Index: 5<br>
+# CHECK-NEXT: Name: .strtab<br>
+# CHECK-NEXT: Type: SHT_STRTAB (0x3)<br>
+# CHECK-NEXT: Flags [ (0x0)<br>
+# CHECK-NEXT: ]<br>
+# CHECK-NEXT: Address: 0x0<br>
+# CHECK-NEXT: Offset: 0x1028<br>
+# CHECK-NEXT: Size: 31<br>
+# CHECK-NEXT: Link: 0<br>
+# CHECK-NEXT: Info: 0<br>
+# CHECK-NEXT: AddressAlignment: 1<br>
+# CHECK-NEXT: EntrySize: 0<br>
+# CHECK-NEXT: }<br>
# CHECK-NEXT: ]<br>
# CHECK-NEXT: ProgramHeaders [<br>
# CHECK-NEXT: ProgramHeader {<br>
@@ -126,8 +140,8 @@ _start:<br>
# CHECK-NEXT: Offset: 0x0<br>
# CHECK-NEXT: VirtualAddress: 0x400000<br>
# CHECK-NEXT: PhysicalAddress: 0x400000<br>
-# CHECK-NEXT: FileSize: 4456<br>
-# CHECK-NEXT: MemSize: 4456<br>
+# CHECK-NEXT: FileSize: 4552<br>
+# CHECK-NEXT: MemSize: 4552<br>
# CHECK-NEXT: Flags [ (0x5)<br>
# CHECK-NEXT: PF_R (0x4)<br>
# CHECK-NEXT: PF_X (0x1)<br>
<br>
Added: lld/trunk/test/elf2/string-table.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/string-table.s?rev=244702&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf2/string-table.s?rev=244702&view=auto</a><br>
==============================================================================<br>
--- lld/trunk/test/elf2/string-table.s (added)<br>
+++ lld/trunk/test/elf2/string-table.s Tue Aug 11 19:00:24 2015<br>
@@ -0,0 +1,32 @@<br>
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t<br>
+// RUN: lld -flavor gnu2 %t -o %t2<br>
+// RUN: llvm-readobj -sections -section-data %t2 | FileCheck %s<br>
+// REQUIRES: x86<br>
+<br>
+.global _start<br>
+_start:<br>
+<br>
+.section bar, "a"<br>
+.section foobar, "a"<br>
+<br>
+// Test that the sting "bar" is merged into "foobar"<br>
+<br>
+// CHECK: Section {<br>
+// CHECK: Index: 6<br>
+// CHECK-NEXT: Name: .strtab<br>
+// CHECK-NEXT: Type: SHT_STRTAB (0x3)<br>
+// CHECK-NEXT: Flags [ (0x0)<br>
+// CHECK-NEXT: ]<br>
+// CHECK-NEXT: Address: 0x0<br>
+// CHECK-NEXT: Offset:<br>
+// CHECK-NEXT: Size: 33<br>
+// CHECK-NEXT: Link: 0<br>
+// CHECK-NEXT: Info: 0<br>
+// CHECK-NEXT: AddressAlignment: 1<br>
+// CHECK-NEXT: EntrySize: 0<br>
+// CHECK-NEXT: SectionData (<br>
+// CHECK-NEXT: 0000: 002E7465 7874002E 62737300 666F6F62 |..text..bss.foob|<br>
+// CHECK-NEXT: 0010: 6172002E 73747274 6162002E 64617461 |ar..strtab..data|<br>
+// CHECK-NEXT: 0020: 00 |.|<br>
+// CHECK-NEXT: )<br>
+// CHECK-NEXT: }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>