[lld] r244702 - ELF: Create a string table.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 17:35:45 PDT 2015


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.

On Tue, Aug 11, 2015 at 5:33 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

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


More information about the llvm-commits mailing list