diff --git a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h index d2850adaeb68..898f36b7902b 100644 --- a/lld/lib/ReaderWriter/ELF/OutputELFWriter.h +++ b/lld/lib/ReaderWriter/ELF/OutputELFWriter.h @@ -248,21 +248,23 @@ template error_code OutputELFWriter::buildOutput(const File &file) { buildChunks(file); - // Call the preFlight callbacks to modify the sections and the atoms - // contained in them, in anyway the targets may want - _layout->doPreFlight(); - // Create the default sections like the symbol table, string table, and the // section string table createDefaultSections(); + // Set the Layout + _layout->assignSectionsToSegments(); + + // Create the dynamic table entries if (_targetInfo.isDynamic()) { _dynamicTable->createDefaultEntries(); buildDynamicSymbolTable(file); } - // Set the Layout - _layout->assignSectionsToSegments(); + // Call the preFlight callbacks to modify the sections and the atoms + // contained in them, in anyway the targets may want + _layout->doPreFlight(); + _layout->assignFileOffsets(); _layout->assignVirtualAddress(); diff --git a/lld/test/elf/Hexagon/dynlib.test b/lld/test/elf/Hexagon/dynlib.test index db2aade5fe80..756464d7a747 100644 --- a/lld/test/elf/Hexagon/dynlib.test +++ b/lld/test/elf/Hexagon/dynlib.test @@ -4,8 +4,8 @@ RUN: llvm-readobj %t1 > %t2 RUN: FileCheck -check-prefix=DYNSYMS %s < %t2 DYNSYMS: Dynamic Symbols: -DYNSYMS: Name Type Address Size FileOffset Flags -DYNSYMS: fn2 FUNC {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} global -DYNSYMS: fn1 FUNC {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} global -DYNSYMS: fn3 FUNC {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} global +DYNSYMS: Name Type Section Address Size FileOffset Flags +DYNSYMS: fn2 FUNC .text {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} global +DYNSYMS: fn1 FUNC .text {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} global +DYNSYMS: fn3 FUNC .text {{[0-9a-f]+}} {{[0-9a-f]+}} {{[0-9a-f]+}} global DYNSYMS: Total: 3 diff --git a/lld/test/elf/sections.objtxt b/lld/test/elf/sections.objtxt index 250f6efb26fc..cc83917c13b1 100644 --- a/lld/test/elf/sections.objtxt +++ b/lld/test/elf/sections.objtxt @@ -17,8 +17,8 @@ READOBJ: File Format : ELF32-i386 READOBJ: Arch : i386 READOBJ: Address Size: 32 bits READOBJ: Symbols -READOBJ: baz FUNC 74 a e8 global -READOBJ: y DATA 1004 4 2008 global +READOBJ: baz FUNC .text 74 a e8 global +READOBJ: y DATA .special 1004 4 2008 global ED: 'e_indent[EI_DATA]', 0x01 ED: 'e_machine', 0x0003