Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -467,9 +467,9 @@ // of the RW segment. static uint64_t getARMStaticBase(const SymbolBody &Body) { OutputSection *OS = Body.getOutputSection(); - if (!OS || !OS->FirstInPtLoad) + if (!OS || !OS->Load || !OS->Load->First) fatal("SBREL relocation to " + Body.getName() + " without static base"); - return OS->FirstInPtLoad->Addr; + return OS->Load->First->Addr; } static uint64_t getRelocTargetVA(uint32_t Type, int64_t A, uint64_t P, Index: ELF/LinkerScript.h =================================================================== --- ELF/LinkerScript.h +++ ELF/LinkerScript.h @@ -283,14 +283,14 @@ void adjustSectionsBeforeSorting(); void adjustSectionsAfterSorting(); - std::vector createPhdrs(); + std::vector createPhdrs(); bool ignoreInterpSection(); bool shouldKeep(InputSectionBase *S); void assignOffsets(OutputSectionCommand *Cmd); void processNonSectionCommands(); void assignAddresses(); - void allocateHeaders(std::vector &Phdrs); + void allocateHeaders(std::vector &Phdrs); void addSymbol(SymbolAssignment *Cmd); void processCommands(OutputSectionFactory &Factory); @@ -301,6 +301,9 @@ extern LinkerScript *Script; } // end namespace elf + +void fill(uint8_t *Buf, size_t Size, uint32_t Filler); + } // end namespace lld #endif // LLD_ELF_LINKER_SCRIPT_H Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -195,7 +195,7 @@ // Fill [Buf, Buf + Size) with Filler. // This is used for linker script "=fillexp" command. -static void fill(uint8_t *Buf, size_t Size, uint32_t Filler) { +void lld::fill(uint8_t *Buf, size_t Size, uint32_t Filler) { size_t I = 0; for (; I + 4 < Size; I += 4) memcpy(Buf + I, &Filler, 4); @@ -799,7 +799,14 @@ } } -void LinkerScript::allocateHeaders(std::vector &Phdrs) { +static OutputSection *getFirstSection(PhdrEntry *Load) { + for (OutputSectionCommand *Cmd : OutputSectionCommands) + if (Cmd->Sec->Load == Load) + return Cmd->Sec; + return nullptr; +} + +void LinkerScript::allocateHeaders(std::vector &Phdrs) { uint64_t Min = std::numeric_limits::max(); for (OutputSectionCommand *Cmd : OutputSectionCommands) { OutputSection *Sec = Cmd->Sec; @@ -807,9 +814,9 @@ Min = std::min(Min, Sec->Addr); } - auto FirstPTLoad = llvm::find_if( - Phdrs, [](const PhdrEntry &E) { return E.p_type == PT_LOAD; }); - if (FirstPTLoad == Phdrs.end()) + auto LoadI = llvm::find_if( + Phdrs, [](const PhdrEntry *E) { return E->p_type == PT_LOAD; }); + if (LoadI == Phdrs.end()) return; uint64_t HeaderSize = getHeaderSize(); @@ -820,28 +827,13 @@ return; } - assert(FirstPTLoad->First == Out::ElfHeader); - OutputSection *ActualFirst = nullptr; - for (OutputSectionCommand *Cmd : OutputSectionCommands) { - OutputSection *Sec = Cmd->Sec; - if (Sec->FirstInPtLoad == Out::ElfHeader) { - ActualFirst = Sec; - break; - } - } - if (ActualFirst) { - for (OutputSectionCommand *Cmd : OutputSectionCommands) { - OutputSection *Sec = Cmd->Sec; - if (Sec->FirstInPtLoad == Out::ElfHeader) - Sec->FirstInPtLoad = ActualFirst; - } - FirstPTLoad->First = ActualFirst; - } else { - Phdrs.erase(FirstPTLoad); - } + assert((*LoadI)->First == Out::ElfHeader); + Out::ElfHeader->Load = nullptr; + Out::ProgramHeaders->Load = nullptr; + (*LoadI)->First = getFirstSection(*LoadI); auto PhdrI = llvm::find_if( - Phdrs, [](const PhdrEntry &E) { return E.p_type == PT_PHDR; }); + Phdrs, [](const PhdrEntry *E) { return E->p_type == PT_PHDR; }); if (PhdrI != Phdrs.end()) Phdrs.erase(PhdrI); } @@ -883,24 +875,25 @@ } // Creates program headers as instructed by PHDRS linker script command. -std::vector LinkerScript::createPhdrs() { - std::vector Ret; +std::vector LinkerScript::createPhdrs() { + std::vector Ret; // Process PHDRS and FILEHDR keywords because they are not // real output sections and cannot be added in the following loop. for (const PhdrsCommand &Cmd : Opt.PhdrsCommands) { - Ret.emplace_back(Cmd.Type, Cmd.Flags == UINT_MAX ? PF_R : Cmd.Flags); - PhdrEntry &Phdr = Ret.back(); + PhdrEntry *Phdr = + make(Cmd.Type, Cmd.Flags == UINT_MAX ? PF_R : Cmd.Flags); if (Cmd.HasFilehdr) - Phdr.add(Out::ElfHeader); + Phdr->add(Out::ElfHeader); if (Cmd.HasPhdrs) - Phdr.add(Out::ProgramHeaders); + Phdr->add(Out::ProgramHeaders); if (Cmd.LMAExpr) { - Phdr.p_paddr = Cmd.LMAExpr().getValue(); - Phdr.HasLMA = true; + Phdr->p_paddr = Cmd.LMAExpr().getValue(); + Phdr->HasLMA = true; } + Ret.push_back(Phdr); } // Add output sections to program headers. @@ -908,9 +901,9 @@ // Assign headers specified by linker script for (size_t Id : getPhdrIndices(Cmd)) { OutputSection *Sec = Cmd->Sec; - Ret[Id].add(Sec); + Ret[Id]->add(Sec); if (Opt.PhdrsCommands[Id].Flags == UINT_MAX) - Ret[Id].p_flags |= Sec->getPhdrFlags(); + Ret[Id]->p_flags |= Sec->getPhdrFlags(); } } return Ret; Index: ELF/OutputSections.h =================================================================== --- ELF/OutputSections.h +++ ELF/OutputSections.h @@ -59,13 +59,14 @@ Alignment = Val; } - // Pointer to the first section in PT_LOAD segment, which this section - // also resides in. This field is used to correctly compute file offset - // of a section. When two sections share the same load segment, difference - // between their file offsets should be equal to difference between their - // virtual addresses. To compute some section offset we use the following - // formula: Off = Off_first + VA - VA_first. - OutputSection *FirstInPtLoad = nullptr; + // Pointer to the PT_LOAD segment, which this section resides in. This field + // is used to correctly compute file offset of a section. When two sections + // share the same load segment, difference between their file offsets should + // be equal to difference between their virtual addresses. To compute some + // section offset we use the following formula: Off = Off_first + VA - + // VA_first, where Off_first and VA_first is file offset and VA of first + // section in PT_LOAD. + PhdrEntry *Load = nullptr; // Pointer to a relocation section for this section. Usually nullptr because // we consume relocations, but if --emit-relocs is specified (which is rare), Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -57,15 +57,16 @@ void finalizeSections(); void addPredefinedSections(); - std::vector createPhdrs(); + std::vector createPhdrs(); void removeEmptyPTLoad(); - void addPtArmExid(std::vector &Phdrs); + void addPtArmExid(std::vector &Phdrs); void assignFileOffsets(); void assignFileOffsetsBinary(); void setPhdrs(); void fixSectionAlignments(); void fixPredefinedSymbols(); void openFile(); + void writeTrapInstr(); void writeHeader(); void writeSections(); void writeSectionsBinary(); @@ -82,7 +83,7 @@ OutputSection *findSectionInScript(StringRef Name); OutputSectionCommand *findSectionCommand(StringRef Name); - std::vector Phdrs; + std::vector Phdrs; uint64_t FileSize; uint64_t SectionHeaderOff; @@ -125,12 +126,12 @@ template void elf::writeResult() { Writer().run(); } template void Writer::removeEmptyPTLoad() { - auto I = std::remove_if(Phdrs.begin(), Phdrs.end(), [&](const PhdrEntry &P) { - if (P.p_type != PT_LOAD) + auto I = llvm::remove_if(Phdrs, [&](const PhdrEntry *P) { + if (P->p_type != PT_LOAD) return false; - if (!P.First) + if (!P->First) return true; - uint64_t Size = P.Last->Addr + P.Last->Size - P.First->Addr; + uint64_t Size = P->Last->Addr + P->Last->Size - P->First->Addr; return Size == 0; }); Phdrs.erase(I, Phdrs.end()); @@ -245,6 +246,7 @@ return; if (!Config->OFormatBinary) { + writeTrapInstr(); writeHeader(); writeSections(); } else { @@ -751,7 +753,7 @@ First = Sec; p_align = std::max(p_align, Sec->Alignment); if (p_type == PT_LOAD) - Sec->FirstInPtLoad = First; + Sec->Load = this; } template @@ -1424,11 +1426,11 @@ // Decide which program headers to create and which sections to include in each // one. -template std::vector Writer::createPhdrs() { - std::vector Ret; +template std::vector Writer::createPhdrs() { + std::vector Ret; auto AddHdr = [&](unsigned Type, unsigned Flags) -> PhdrEntry * { - Ret.emplace_back(Type, Flags); - return &Ret.back(); + Ret.push_back(make(Type, Flags)); + return Ret.back(); }; // The first phdr entry is PT_PHDR which describes the program header itself. @@ -1468,14 +1470,14 @@ } // Add a TLS segment if any. - PhdrEntry TlsHdr(PT_TLS, PF_R); + PhdrEntry *TlsHdr = make(PT_TLS, PF_R); for (OutputSectionCommand *Cmd : OutputSectionCommands) { OutputSection *Sec = Cmd->Sec; if (Sec->Flags & SHF_TLS) - TlsHdr.add(Sec); + TlsHdr->add(Sec); } - if (TlsHdr.First) - Ret.push_back(std::move(TlsHdr)); + if (TlsHdr->First) + Ret.push_back(TlsHdr); // Add an entry for .dynamic. if (InX::DynSymTab) @@ -1484,14 +1486,14 @@ // PT_GNU_RELRO includes all sections that should be marked as // read-only by dynamic linker after proccessing relocations. - PhdrEntry RelRo(PT_GNU_RELRO, PF_R); + PhdrEntry *RelRo = make(PT_GNU_RELRO, PF_R); for (OutputSectionCommand *Cmd : OutputSectionCommands) { OutputSection *Sec = Cmd->Sec; if (needsPtLoad(Sec) && isRelroSection(Sec)) - RelRo.add(Sec); + RelRo->add(Sec); } - if (RelRo.First) - Ret.push_back(std::move(RelRo)); + if (RelRo->First) + Ret.push_back(RelRo); // PT_GNU_EH_FRAME is a special section pointing on .eh_frame_hdr. if (!In::EhFrame->empty() && In::EhFrameHdr && @@ -1538,7 +1540,7 @@ } template -void Writer::addPtArmExid(std::vector &Phdrs) { +void Writer::addPtArmExid(std::vector &Phdrs) { if (Config->EMachine != EM_ARM) return; auto I = llvm::find_if(OutputSectionCommands, [](OutputSectionCommand *Cmd) { @@ -1548,8 +1550,8 @@ return; // PT_ARM_EXIDX is the ARM EHABI equivalent of PT_GNU_EH_FRAME - PhdrEntry ARMExidx(PT_ARM_EXIDX, PF_R); - ARMExidx.add((*I)->Sec); + PhdrEntry *ARMExidx = make(PT_ARM_EXIDX, PF_R); + ARMExidx->add((*I)->Sec); Phdrs.push_back(ARMExidx); } @@ -1565,20 +1567,20 @@ }; }; - for (const PhdrEntry &P : Phdrs) - if (P.p_type == PT_LOAD && P.First) - PageAlign(P.First); + for (const PhdrEntry *P : Phdrs) + if (P->p_type == PT_LOAD && P->First) + PageAlign(P->First); - for (const PhdrEntry &P : Phdrs) { - if (P.p_type != PT_GNU_RELRO) + for (const PhdrEntry *P : Phdrs) { + if (P->p_type != PT_GNU_RELRO) continue; - if (P.First) - PageAlign(P.First); + if (P->First) + PageAlign(P->First); // Find the first section after PT_GNU_RELRO. If it is in a PT_LOAD we // have to align it to a page. auto End = OutputSectionCommands.end(); auto I = - std::find(OutputSectionCommands.begin(), End, Script->getCmd(P.Last)); + std::find(OutputSectionCommands.begin(), End, Script->getCmd(P->Last)); if (I == End || (I + 1) == End) continue; OutputSection *Sec = (*(I + 1))->Sec; @@ -1592,7 +1594,7 @@ // virtual address (modulo the page size) so that the loader can load // executables without any address adjustment. static uint64_t getFileAlignment(uint64_t Off, OutputSection *Sec) { - OutputSection *First = Sec->FirstInPtLoad; + OutputSection *First = Sec->Load ? Sec->Load->First : nullptr; // If the section is not in a PT_LOAD, we just have to align it. if (!First) return alignTo(Off, Sec->Alignment); @@ -1628,15 +1630,42 @@ FileSize = alignTo(Off, Config->Wordsize); } +static std::vector getAllPtLoads(ArrayRef V) { + std::vector Ret = V.vec(); + llvm::erase_if(Ret, [](PhdrEntry *E) { return E->p_type != PT_LOAD; }); + return Ret; +} + +static std::vector getExecLoads(ArrayRef V) { + std::vector Ret; + for (PhdrEntry *Load : getAllPtLoads(V)) + if (Load->p_flags & PF_X) + Ret.push_back(Load); + return Ret; +} + // Assign file offsets to output sections. template void Writer::assignFileOffsets() { uint64_t Off = 0; Off = setOffset(Out::ElfHeader, Off); Off = setOffset(Out::ProgramHeaders, Off); - for (OutputSectionCommand *Cmd : OutputSectionCommands) + std::vector ExecLoads = getExecLoads(Phdrs); + for (OutputSectionCommand *Cmd : OutputSectionCommands) { Off = setOffset(Cmd->Sec, Off); + if (Script->Opt.HasSections) + continue; + + // If no linker script is involved and allocatable section is the last in + // executable segment, that means we want to ensure segment contains only + // valid instructions and hence we align next section's offset to avoid + // loading of non-allocatable content. We will fill gap with trap op codes. + if (!ExecLoads.empty()) + if (Cmd->Sec == ExecLoads.back()->Last) + Off = alignTo(Off, Target->PageSize); + } + SectionHeaderOff = alignTo(Off, Config->Wordsize); FileSize = SectionHeaderOff + (OutputSectionCommands.size() + 1) * sizeof(Elf_Shdr); @@ -1645,35 +1674,35 @@ // Finalize the program headers. We call this function after we assign // file offsets and VAs to all sections. template void Writer::setPhdrs() { - for (PhdrEntry &P : Phdrs) { - OutputSection *First = P.First; - OutputSection *Last = P.Last; + for (PhdrEntry *P : Phdrs) { + OutputSection *First = P->First; + OutputSection *Last = P->Last; if (First) { - P.p_filesz = Last->Offset - First->Offset; + P->p_filesz = Last->Offset - First->Offset; if (Last->Type != SHT_NOBITS) - P.p_filesz += Last->Size; - P.p_memsz = Last->Addr + Last->Size - First->Addr; - P.p_offset = First->Offset; - P.p_vaddr = First->Addr; - if (!P.HasLMA) - P.p_paddr = First->getLMA(); + P->p_filesz += Last->Size; + P->p_memsz = Last->Addr + Last->Size - First->Addr; + P->p_offset = First->Offset; + P->p_vaddr = First->Addr; + if (!P->HasLMA) + P->p_paddr = First->getLMA(); } - if (P.p_type == PT_LOAD) - P.p_align = Config->MaxPageSize; - else if (P.p_type == PT_GNU_RELRO) { - P.p_align = 1; + if (P->p_type == PT_LOAD) + P->p_align = Config->MaxPageSize; + else if (P->p_type == PT_GNU_RELRO) { + P->p_align = 1; // The glibc dynamic loader rounds the size down, so we need to round up // to protect the last page. This is a no-op on FreeBSD which always // rounds up. - P.p_memsz = alignTo(P.p_memsz, Target->PageSize); + P->p_memsz = alignTo(P->p_memsz, Target->PageSize); } // The TLS pointer goes after PT_TLS. At least glibc will align it, // so round up the size to make sure the offsets are correct. - if (P.p_type == PT_TLS) { - Out::TlsPhdr = &P; - if (P.p_memsz) - P.p_memsz = alignTo(P.p_memsz, P.p_align); + if (P->p_type == PT_TLS) { + Out::TlsPhdr = P; + if (P->p_memsz) + P->p_memsz = alignTo(P->p_memsz, P->p_align); } } } @@ -1727,14 +1756,14 @@ PhdrEntry *Last = nullptr; PhdrEntry *LastRO = nullptr; PhdrEntry *LastRW = nullptr; - for (PhdrEntry &P : Phdrs) { - if (P.p_type != PT_LOAD) + for (PhdrEntry *P : Phdrs) { + if (P->p_type != PT_LOAD) continue; - Last = &P; - if (P.p_flags & PF_W) - LastRW = &P; + Last = P; + if (P->p_flags & PF_W) + LastRW = P; else - LastRO = &P; + LastRO = P; } auto Set = [](DefinedRegular *S, OutputSection *Sec, uint64_t Value) { @@ -1811,15 +1840,15 @@ // Write the program header table. auto *HBuf = reinterpret_cast(Buf + EHdr->e_phoff); - for (PhdrEntry &P : Phdrs) { - HBuf->p_type = P.p_type; - HBuf->p_flags = P.p_flags; - HBuf->p_offset = P.p_offset; - HBuf->p_vaddr = P.p_vaddr; - HBuf->p_paddr = P.p_paddr; - HBuf->p_filesz = P.p_filesz; - HBuf->p_memsz = P.p_memsz; - HBuf->p_align = P.p_align; + for (PhdrEntry *P : Phdrs) { + HBuf->p_type = P->p_type; + HBuf->p_flags = P->p_flags; + HBuf->p_offset = P->p_offset; + HBuf->p_vaddr = P->p_vaddr; + HBuf->p_paddr = P->p_paddr; + HBuf->p_filesz = P->p_filesz; + HBuf->p_memsz = P->p_memsz; + HBuf->p_align = P->p_align; ++HBuf; } @@ -1856,6 +1885,34 @@ } } +static void fillPage(uint8_t *Buf, uint64_t Offset, uint32_t Filler) { + uint64_t Begin = alignDown(Offset, Target->PageSize); + uint64_t End = alignTo(Offset, Target->PageSize); + fill(Buf + Begin, End - Begin, Filler); +} + +template void Writer::writeTrapInstr() { + // FIXME: do the same for case when sections present. + if (Script->Opt.HasSections) + return; + + uint8_t *Buf = Buffer->getBufferStart(); + for (PhdrEntry *Load : getExecLoads(Phdrs)) { + // We only fill the first and the last page of the segment because the + // middle part will be overwritten by output sections. + fillPage(Buf, Load->p_offset, Target->TrapInstr); + fillPage(Buf, Load->p_offset + Load->p_filesz, Target->TrapInstr); + } + + // Round up the file size of the last segment to the page boundary if it is + // an executable segment to ensure that other other tools don't accidentally + // trim the instruction padding (e.g. when stripping the file). + std::vector V = getAllPtLoads(Phdrs); + PhdrEntry *Last = V.empty() ? nullptr : V.back(); + if (Last && (Last->p_flags & PF_X)) + Last->p_filesz = alignTo(Last->p_filesz, Target->PageSize); +} + // Write section contents to a mmap'ed file. template void Writer::writeSections() { uint8_t *Buf = Buffer->getBufferStart(); Index: test/ELF/avoid-empty-program-headers.s =================================================================== --- test/ELF/avoid-empty-program-headers.s +++ test/ELF/avoid-empty-program-headers.s @@ -42,7 +42,7 @@ // CHECK-NEXT: Offset: 0x1000 // CHECK-NEXT: VirtualAddress: 0x201000 // CHECK-NEXT: PhysicalAddress: 0x201000 -// CHECK-NEXT: FileSize: 1 +// CHECK-NEXT: FileSize: 4096 // CHECK-NEXT: MemSize: 1 // CHECK-NEXT: Flags [ (0x5) // CHECK-NEXT: PF_R (0x4) @@ -52,7 +52,7 @@ // CHECK-NEXT: } // CHECK-NEXT: ProgramHeader { // CHECK-NEXT: Type: PT_TLS (0x7) -// CHECK-NEXT: Offset: 0x1001 +// CHECK-NEXT: Offset: 0x2000 // CHECK-NEXT: VirtualAddress: 0x201001 // CHECK-NEXT: PhysicalAddress: 0x201001 // CHECK-NEXT: FileSize: 0 Index: test/ELF/basic-aarch64.s =================================================================== --- test/ELF/basic-aarch64.s +++ test/ELF/basic-aarch64.s @@ -26,7 +26,7 @@ # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]] # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x10098 +# CHECK-NEXT: SectionHeaderOffset: 0x11088 # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 @@ -76,7 +76,7 @@ # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1000C +# CHECK-NEXT: Offset: 0x11000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -90,7 +90,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x10018 +# CHECK-NEXT: Offset: 0x11008 # CHECK-NEXT: Size: 72 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 2 @@ -104,7 +104,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x10060 +# CHECK-NEXT: Offset: 0x11050 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -118,7 +118,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1008A +# CHECK-NEXT: Offset: 0x1107A # CHECK-NEXT: Size: 13 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -185,7 +185,7 @@ # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x20000 # CHECK-NEXT: PhysicalAddress: 0x20000 -# CHECK-NEXT: FileSize: 12 +# CHECK-NEXT: FileSize: 4096 # CHECK-NEXT: MemSize: 12 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) Index: test/ELF/basic-sparcv9.s =================================================================== --- test/ELF/basic-sparcv9.s +++ test/ELF/basic-sparcv9.s @@ -26,7 +26,7 @@ # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]] # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x100080 +# CHECK-NEXT: SectionHeaderOffset: 0x102070 # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 @@ -76,7 +76,7 @@ # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x10000C +# CHECK-NEXT: Offset: 0x102000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -90,7 +90,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100018 +# CHECK-NEXT: Offset: 0x102008 # CHECK-NEXT: Size: 48 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 @@ -104,7 +104,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100048 +# CHECK-NEXT: Offset: 0x102038 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -118,7 +118,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100072 +# CHECK-NEXT: Offset: 0x102062 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -176,7 +176,7 @@ # CHECK-NEXT: Offset: 0x100000 # CHECK-NEXT: VirtualAddress: 0x200000 # CHECK-NEXT: PhysicalAddress: 0x200000 -# CHECK-NEXT: FileSize: 12 +# CHECK-NEXT: FileSize: 8192 # CHECK-NEXT: MemSize: 12 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) Index: test/ELF/basic.s =================================================================== --- test/ELF/basic.s +++ test/ELF/basic.s @@ -28,7 +28,7 @@ # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]] # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x1080 +# CHECK-NEXT: SectionHeaderOffset: 0x2070 # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 @@ -78,7 +78,7 @@ # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1010 +# CHECK-NEXT: Offset: 0x2000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -92,7 +92,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1018 +# CHECK-NEXT: Offset: 0x2008 # CHECK-NEXT: Size: 48 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 @@ -106,7 +106,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1048 +# CHECK-NEXT: Offset: 0x2038 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -120,7 +120,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1072 +# CHECK-NEXT: Offset: 0x2062 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -178,7 +178,7 @@ # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x201000 # CHECK-NEXT: PhysicalAddress: 0x201000 -# CHECK-NEXT: FileSize: 16 +# CHECK-NEXT: FileSize: 4096 # CHECK-NEXT: MemSize: 16 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) Index: test/ELF/basic32.s =================================================================== --- test/ELF/basic32.s +++ test/ELF/basic32.s @@ -25,7 +25,7 @@ # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: 0x11000 # CHECK-NEXT: ProgramHeaderOffset: 0x34 -# CHECK-NEXT: SectionHeaderOffset: 0x1068 +# CHECK-NEXT: SectionHeaderOffset: 0x205C # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 52 @@ -75,7 +75,7 @@ # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100C +# CHECK-NEXT: Offset: 0x2000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -89,7 +89,7 @@ # CHECK-NEXT: Flags [ # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1014 +# CHECK-NEXT: Offset: 0x2008 # CHECK-NEXT: Size: 32 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 @@ -103,7 +103,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1034 +# CHECK-NEXT: Offset: 0x2028 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -117,7 +117,7 @@ # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x105E +# CHECK-NEXT: Offset: 0x2052 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -155,7 +155,7 @@ # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x11000 # CHECK-NEXT: PhysicalAddress: 0x11000 -# CHECK-NEXT: FileSize: 12 +# CHECK-NEXT: FileSize: 4096 # CHECK-NEXT: MemSize: 12 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) Index: test/ELF/build-id.s =================================================================== --- test/ELF/build-id.s +++ test/ELF/build-id.s @@ -48,7 +48,7 @@ # DEFAULT: Contents of section .note.test: # DEFAULT: Contents of section .note.gnu.build-id: # DEFAULT-NEXT: 04000000 08000000 03000000 474e5500 ............GNU. -# DEFAULT-NEXT: fd36edb1 f6ff02af +# DEFAULT-NEXT: b0148597 ba5eb7e9 # MD5: Contents of section .note.gnu.build-id: # MD5-NEXT: 04000000 10000000 03000000 474e5500 ............GNU. @@ -56,7 +56,7 @@ # SHA1: Contents of section .note.gnu.build-id: # SHA1-NEXT: 04000000 14000000 03000000 474e5500 ............GNU. -# SHA1-NEXT: 55b1eedb 03b588e1 09987d1d e9a79be7 +# SHA1-NEXT: 2f716666 fe3668fe 370a02a1 579c3eb2 # UUID: Contents of section .note.gnu.build-id: # UUID-NEXT: 04000000 10000000 03000000 474e5500 ............GNU. Index: test/ELF/image-base.s =================================================================== --- test/ELF/image-base.s +++ test/ELF/image-base.s @@ -41,7 +41,7 @@ # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x1001000 # CHECK-NEXT: PhysicalAddress: 0x1001000 -# CHECK-NEXT: FileSize: 1 +# CHECK-NEXT: FileSize: 4096 # CHECK-NEXT: MemSize: 1 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) Index: test/ELF/relocatable.s =================================================================== --- test/ELF/relocatable.s +++ test/ELF/relocatable.s @@ -81,7 +81,7 @@ # CHECKEXE-NEXT: Version: 1 # CHECKEXE-NEXT: Entry: 0x201000 # CHECKEXE-NEXT: ProgramHeaderOffset: 0x40 -# CHECKEXE-NEXT: SectionHeaderOffset: 0x11F8 +# CHECKEXE-NEXT: SectionHeaderOffset: 0x21A0 # CHECKEXE-NEXT: Flags [ # CHECKEXE-NEXT: ] # CHECKEXE-NEXT: HeaderSize: 64