Index: lld/ELF/Arch/PPC64.cpp =================================================================== --- lld/ELF/Arch/PPC64.cpp +++ lld/ELF/Arch/PPC64.cpp @@ -72,13 +72,9 @@ GotBaseSymInGotPlt = false; GotBaseSymOff = 0x8000; - if (Config->EKind == ELF64LEKind) { - GotHeaderEntriesNum = 1; - GotPltHeaderEntriesNum = 2; - PltRel = R_PPC64_JMP_SLOT; - } else { - PltRel = R_PPC64_GLOB_DAT; - } + GotHeaderEntriesNum = 1; + GotPltHeaderEntriesNum = 2; + PltRel = R_PPC64_JMP_SLOT; // We need 64K pages (at least under glibc/Linux, the loader won't // set different permissions on a finer granularity than that). @@ -99,39 +95,57 @@ } static uint32_t getEFlags(InputFile *File) { - // Get the e_flag from the input file and if it is unspecified, then set it to - // the e_flag appropriate for the ABI. + // Get the e_flag from the input file and issue an error if incompatible + // e_flag encountered. + + assert((Config->EKind == ELF64BEKind || + Config->EKind == ELF64LEKind) && "unknown Config->EKind"); + uint32_t EFlags = Config->EKind == ELF64LEKind ? + cast>(File)->getObj().getHeader()->e_flags : + cast>(File)->getObj().getHeader()->e_flags; + if (EFlags != 0 && EFlags != 1 && EFlags != 2) + error("incompatible e_flags: " + toString(File)); + return EFlags; +} - // We are currently handling both ELF64LE and ELF64BE but eventually will - // remove BE support once v2 ABI support is complete. - switch (Config->EKind) { - case ELF64BEKind: - if (uint32_t EFlags = - cast>(File)->getObj().getHeader()->e_flags) - return EFlags; - return 1; - case ELF64LEKind: - if (uint32_t EFlags = - cast>(File)->getObj().getHeader()->e_flags) - return EFlags; - return 2; +static StringRef getABIName(uint32_t Flags) { + switch (Flags) { + case 1: + return "V1"; + case 2: + return "V2"; default: - llvm_unreachable("unknown Config->EKind"); + return "unknown"; } } uint32_t PPC64::calcEFlags() const { assert(!ObjectFiles.empty()); - uint32_t Ret = getEFlags(ObjectFiles[0]); - // Verify that all input files have the same e_flags. - for (InputFile *F : makeArrayRef(ObjectFiles).slice(1)) { - if (Ret == getEFlags(F)) + uint32_t NonZeroFlag; + for (InputFile *F : makeArrayRef(ObjectFiles)) { + NonZeroFlag = getEFlags(F); + if (NonZeroFlag) + break; + } + + // Verify that all input files have either the same e_flags, or zero. + for (InputFile *F : makeArrayRef(ObjectFiles)) { + uint32_t Flag = getEFlags(F); + if (Flag == 0 || Flag == NonZeroFlag) continue; - error("incompatible e_flags: " + toString(F)); + error(toString(F) + ": ABI version " + getABIName(Flag) + + " is not compatible with ABI version " + getABIName(NonZeroFlag) + + " output"); return 0; } - return Ret; + + if (NonZeroFlag == 1) { + error("PPC64 V1 ABI not supported"); + return 0; + } + + return 2; } RelExpr PPC64::getRelExpr(RelType Type, const Symbol &S, @@ -147,7 +161,7 @@ case R_PPC64_TOC: return R_PPC_TOC; case R_PPC64_REL24: - return R_PPC_PLT_OPD; + return R_PLT_PC; case R_PPC64_REL16_LO: case R_PPC64_REL16_HA: return R_PC; @@ -157,8 +171,7 @@ } void PPC64::writeGotHeader(uint8_t *Buf) const { - if (Config->EKind == ELF64LEKind) - write64(Buf, getPPC64TocBase()); + write64(Buf, getPPC64TocBase()); } void PPC64::writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, @@ -166,37 +179,21 @@ unsigned RelOff) const { uint64_t Off = GotPltEntryAddr - getPPC64TocBase(); - if (Config->EKind == ELF64LEKind) { - // The most-common form of the plt stub. This assumes that the toc-pointer - // register is properly initalized, and that the stub must save the toc - // pointer value to the stack-save slot reserved for it (sp + 24). - // There are 2 other variants but we don't have to emit those until we add - // support for R_PPC64_REL24_NOTOC and R_PPC64_TOCSAVE relocations. - // We are missing a super simple optimization, where if the upper 16 bits of - // the offset are zero, then we can omit the addis instruction, and load - // r2 + lo-offset directly into r12. I decided to leave this out in the - // spirit of keeping it simple until we can link actual non-trivial - // programs. - write32(Buf + 0, 0xf8410018); // std r2,24(r1) - write32(Buf + 4, 0x3d820000 | applyPPCHa(Off)); // addis r12,r2, X@plt@to@ha - write32(Buf + 8, 0xe98c0000 | applyPPCLo(Off)); // ld r12,X@plt@toc@l(r12) - write32(Buf + 12, 0x7d8903a6); // mtctr r12 - write32(Buf + 16, 0x4e800420); // bctr - } else { - // FIXME: What we should do, in theory, is get the offset of the function - // descriptor in the .opd section, and use that as the offset from %r2 (the - // TOC-base pointer). Instead, we have the GOT-entry offset, and that will - // be a pointer to the function descriptor in the .opd section. Using - // this scheme is simpler, but requires an extra indirection per PLT dispatch. - write32(Buf, 0xf8410028); // std %r2, 40(%r1) - write32(Buf + 4, 0x3d620000 | applyPPCHa(Off)); // addis %r11, %r2, X@ha - write32(Buf + 8, 0xe98b0000 | applyPPCLo(Off)); // ld %r12, X@l(%r11) - write32(Buf + 12, 0xe96c0000); // ld %r11,0(%r12) - write32(Buf + 16, 0x7d6903a6); // mtctr %r11 - write32(Buf + 20, 0xe84c0008); // ld %r2,8(%r12) - write32(Buf + 24, 0xe96c0010); // ld %r11,16(%r12) - write32(Buf + 28, 0x4e800420); // bctr - } + // The most-common form of the plt stub. This assumes that the toc-pointer + // register is properly initalized, and that the stub must save the toc + // pointer value to the stack-save slot reserved for it (sp + 24). + // There are 2 other variants but we don't have to emit those until we add + // support for R_PPC64_REL24_NOTOC and R_PPC64_TOCSAVE relocations. + // We are missing a super simple optimization, where if the upper 16 bits of + // the offset are zero, then we can omit the addis instruction, and load + // r2 + lo-offset directly into r12. I decided to leave this out in the + // spirit of keeping it simple until we can link actual non-trivial + // programs. + write32(Buf + 0, 0xf8410018); // std r2,24(r1) + write32(Buf + 4, 0x3d820000 | applyPPCHa(Off)); // addis r12,r2, X@plt@to@ha + write32(Buf + 8, 0xe98c0000 | applyPPCLo(Off)); // ld r12,X@plt@toc@l(r12) + write32(Buf + 12, 0x7d8903a6); // mtctr r12 + write32(Buf + 16, 0x4e800420); // bctr } static std::pair toAddr16Rel(RelType Type, uint64_t Val) { Index: lld/ELF/InputSection.cpp =================================================================== --- lld/ELF/InputSection.cpp +++ lld/ELF/InputSection.cpp @@ -556,6 +556,8 @@ Dest = getARMUndefinedRelativeWeakVA(Type, A, P); else if (Config->EMachine == EM_AARCH64) Dest = getAArch64UndefinedRelativeWeakVA(Type, A, P); + else if (Config->EMachine == EM_PPC64) + return 0; else Dest = Sym.getVA(A); } else { @@ -566,26 +568,7 @@ case R_PLT: return Sym.getPltVA() + A; case R_PLT_PC: - case R_PPC_PLT_OPD: return Sym.getPltVA() + A - P; - case R_PPC_OPD: { - uint64_t SymVA = Sym.getVA(A); - // If we have an undefined weak symbol, we might get here with a symbol - // address of zero. That could overflow, but the code must be unreachable, - // so don't bother doing anything at all. - if (!SymVA) - return 0; - if (Out::Opd) { - // If this is a local call, and we currently have the address of a - // function-descriptor, get the underlying code address instead. - uint64_t OpdStart = Out::Opd->Addr; - uint64_t OpdEnd = OpdStart + Out::Opd->Size; - bool InOpd = OpdStart <= SymVA && SymVA < OpdEnd; - if (InOpd) - SymVA = read64be(&Out::OpdBuf[SymVA - OpdStart]); - } - return SymVA - P; - } case R_PPC_TOC: return getPPC64TocBase() + A; case R_RELAX_GOT_PC: @@ -738,13 +721,15 @@ case R_RELAX_TLS_GD_TO_IE_END: Target->relaxTlsGdToIe(BufLoc, Type, TargetVA); break; - case R_PPC_PLT_OPD: - // Patch a nop (0x60000000) to a ld. - if (BufLoc + 8 > BufEnd || read32(BufLoc + 4) != 0x60000000) { - error(getErrorLocation(BufLoc) + "call lacks nop, can't restore toc"); - break; + case R_PLT_PC: + if (Config->EMachine == EM_PPC64) { + // Patch a nop (0x60000000) to a ld. + if (BufLoc + 8 > BufEnd || read32(BufLoc + 4) != 0x60000000) { + error(getErrorLocation(BufLoc) + "call lacks nop, can't restore toc"); + break; + } + write32(BufLoc + 4, 0xe8410018); // ld %r2, 24(%r1) } - write32(BufLoc + 4, 0xe8410018); // ld %r2, 24(%r1) Target->relocateOne(BufLoc, Type, TargetVA); break; default: Index: lld/ELF/OutputSections.h =================================================================== --- lld/ELF/OutputSections.h +++ lld/ELF/OutputSections.h @@ -128,8 +128,6 @@ // until Writer is initialized. struct Out { static uint8_t First; - static OutputSection *Opd; - static uint8_t *OpdBuf; static PhdrEntry *TlsPhdr; static OutputSection *DebugInfo; static OutputSection *ElfHeader; Index: lld/ELF/OutputSections.cpp =================================================================== --- lld/ELF/OutputSections.cpp +++ lld/ELF/OutputSections.cpp @@ -31,8 +31,6 @@ using namespace lld::elf; uint8_t Out::First; -OutputSection *Out::Opd; -uint8_t *Out::OpdBuf; PhdrEntry *Out::TlsPhdr; OutputSection *Out::DebugInfo; OutputSection *Out::ElfHeader; Index: lld/ELF/Relocations.h =================================================================== --- lld/ELF/Relocations.h +++ lld/ELF/Relocations.h @@ -59,8 +59,6 @@ R_PLT, R_PLT_PAGE_PC, R_PLT_PC, - R_PPC_OPD, - R_PPC_PLT_OPD, R_PPC_TOC, R_RELAX_GOT_PC, R_RELAX_GOT_PC_NOPIC, Index: lld/ELF/Relocations.cpp =================================================================== --- lld/ELF/Relocations.cpp +++ lld/ELF/Relocations.cpp @@ -312,7 +312,7 @@ // Returns true if Expr refers a PLT entry. static bool needsPlt(RelExpr Expr) { - return isRelExprOneOf(Expr); + return isRelExprOneOf(Expr); } // Returns true if Expr refers a GOT entry. Note that this function @@ -347,7 +347,7 @@ R_MIPS_GOTREL, R_MIPS_GOT_OFF, R_MIPS_GOT_OFF32, R_MIPS_GOT_GP_PC, R_MIPS_TLSGD, R_GOT_PAGE_PC, R_GOT_PC, R_GOTONLY_PC, R_GOTONLY_PC_FROM_END, R_PLT_PC, R_TLSGD_PC, - R_TLSGD, R_PPC_PLT_OPD, R_TLSDESC_CALL, R_TLSDESC_PAGE, + R_TLSGD, R_TLSDESC_CALL, R_TLSDESC_PAGE, R_HINT>(E)) return true; @@ -395,8 +395,6 @@ static RelExpr toPlt(RelExpr Expr) { switch (Expr) { - case R_PPC_OPD: - return R_PPC_PLT_OPD; case R_PC: return R_PLT_PC; case R_PAGE_PC: @@ -414,8 +412,6 @@ switch (Expr) { case R_PLT_PC: return R_PC; - case R_PPC_PLT_OPD: - return R_PPC_OPD; case R_PLT: return R_ABS; default: Index: lld/ELF/Writer.cpp =================================================================== --- lld/ELF/Writer.cpp +++ lld/ELF/Writer.cpp @@ -689,7 +689,6 @@ RF_BSS = 1 << 8, RF_NOTE = 1 << 7, RF_PPC_NOT_TOCBSS = 1 << 6, - RF_PPC_OPD = 1 << 5, RF_PPC_TOCL = 1 << 4, RF_PPC_TOC = 1 << 3, RF_PPC_BRANCH_LT = 1 << 2, @@ -794,9 +793,6 @@ if (Name != ".tocbss") Rank |= RF_PPC_NOT_TOCBSS; - if (Name == ".opd") - Rank |= RF_PPC_OPD; - if (Name == ".toc1") Rank |= RF_PPC_TOCL; @@ -2295,14 +2291,6 @@ template void Writer::writeSections() { uint8_t *Buf = Buffer->getBufferStart(); - // PPC64 needs to process relocations in the .opd section - // before processing relocations in code-containing sections. - if (auto *OpdCmd = findSection(".opd")) { - Out::Opd = OpdCmd; - Out::OpdBuf = Buf + Out::Opd->Offset; - OpdCmd->template writeTo(Buf + Out::Opd->Offset); - } - OutputSection *EhFrameHdr = nullptr; if (InX::EhFrameHdr && !InX::EhFrameHdr->empty()) EhFrameHdr = InX::EhFrameHdr->getParent(); @@ -2315,8 +2303,7 @@ Sec->writeTo(Buf + Sec->Offset); for (OutputSection *Sec : OutputSections) - if (Sec != Out::Opd && Sec != EhFrameHdr && Sec->Type != SHT_REL && - Sec->Type != SHT_RELA) + if (Sec != EhFrameHdr && Sec->Type != SHT_REL && Sec->Type != SHT_RELA) Sec->writeTo(Buf + Sec->Offset); // The .eh_frame_hdr depends on .eh_frame section contents, therefore Index: lld/test/ELF/Inputs/shared-ppc64.s =================================================================== --- lld/test/ELF/Inputs/shared-ppc64.s +++ /dev/null @@ -1,9 +0,0 @@ -.section ".opd","aw" -.global bar -bar: -.quad .Lbar,.TOC.@tocbase,0 -.quad .Lbar,0,0 - -.text -.Lbar: - blr Index: lld/test/ELF/basic64be.s =================================================================== --- lld/test/ELF/basic64be.s +++ lld/test/ELF/basic64be.s @@ -4,26 +4,11 @@ # REQUIRES: ppc # exits with return code 42 on linux -.section ".opd","aw" -.global _start -_start: -.quad .Lfoo,.TOC.@tocbase,0 - -# generate .toc and .toc1 sections to make sure that the ordering is as -# intended (.toc before .toc1, and both before .opd). -.section ".toc1","aw" -.quad 22, 37, 89, 47 - -.section ".toc","aw" -.quad 45, 86, 72, 24 - .text -.Lfoo: li 0,1 li 3,42 sc - -# CHECK: ElfHeader { +# CHECK: ElfHeader { # CHECK-NEXT: Ident { # CHECK-NEXT: Magic: (7F 45 4C 46) # CHECK-NEXT: Class: 64-bit (0x2) @@ -36,18 +21,18 @@ # CHECK-NEXT: Type: Executable (0x2) # CHECK-NEXT: Machine: EM_PPC64 (0x15) # CHECK-NEXT: Version: 1 -# CHECK-NEXT: Entry: 0x10020040 +# CHECK-NEXT: Entry: 0x10010000 # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x30080 -# CHECK-NEXT: Flags [ (0x1) -# CHECK-NEXT: 0x1 +# CHECK-NEXT: SectionHeaderOffset: 0x11050 +# CHECK-NEXT: Flags [ (0x2) +# CHECK-NEXT: 0x2 # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 # CHECK-NEXT: ProgramHeaderEntrySize: 56 -# CHECK-NEXT: ProgramHeaderCount: 6 +# CHECK-NEXT: ProgramHeaderCount: 4 # CHECK-NEXT: SectionHeaderEntrySize: 64 -# CHECK-NEXT: SectionHeaderCount: 10 -# CHECK-NEXT: StringTableSectionIndex: 8 +# CHECK-NEXT: SectionHeaderCount: 6 +# CHECK-NEXT: StringTableSectionIndex: 4 # CHECK-NEXT: } # CHECK-NEXT: Sections [ # CHECK-NEXT: Section { @@ -68,7 +53,7 @@ # CHECK-NEXT: } # CHECK-NEXT: Section { # CHECK-NEXT: Index: 1 -# CHECK-NEXT: Name: .text +# CHECK-NEXT: Name: .text (1) # CHECK-NEXT: Type: SHT_PROGBITS (0x1) # CHECK-NEXT: Flags [ (0x6) # CHECK-NEXT: SHF_ALLOC (0x2) @@ -82,152 +67,80 @@ # CHECK-NEXT: AddressAlignment: 4 # CHECK-NEXT: EntrySize: 0 # CHECK-NEXT: SectionData ( -# CHECK: ) -# CHECK-NEXT: } -# CHECK-NEXT: Section { -# CHECK-NEXT: Index: 2 -# CHECK-NEXT: Name: .toc -# CHECK-NEXT: Type: SHT_PROGBITS (0x1) -# CHECK-NEXT: Flags [ (0x3) -# CHECK-NEXT: SHF_ALLOC (0x2) -# CHECK-NEXT: SHF_WRITE (0x1) -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x10020000 -# CHECK-NEXT: Offset: 0x20000 -# CHECK-NEXT: Size: 32 -# CHECK-NEXT: Link: 0 -# CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 -# CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 00000000 0000002D 00000000 00000056 |.......-.......V| -# CHECK-NEXT: 0010: 00000000 00000048 00000000 00000018 |.......H........| +# CHECK-NEXT: 0000: 38000001 3860002A 44000002 |8...8`.*D...| # CHECK-NEXT: ) # CHECK-NEXT: } # CHECK-NEXT: Section { -# CHECK-NEXT: Index: 3 -# CHECK-NEXT: Name: .toc1 -# CHECK-NEXT: Type: SHT_PROGBITS (0x1) -# CHECK-NEXT: Flags [ (0x3) -# CHECK-NEXT: SHF_ALLOC (0x2) -# CHECK-NEXT: SHF_WRITE (0x1) -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x10020020 -# CHECK-NEXT: Offset: 0x20020 -# CHECK-NEXT: Size: 32 -# CHECK-NEXT: Link: 0 -# CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 -# CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 00000000 00000016 00000000 00000025 |...............%| -# CHECK-NEXT: 0010: 00000000 00000059 00000000 0000002F |.......Y......./| -# CHECK-NEXT: ) -# CHECK-NEXT: } -# CHECK-NEXT: Section { -# CHECK-NEXT: Index: 4 -# CHECK-NEXT: Name: .opd -# CHECK-NEXT: Type: SHT_PROGBITS (0x1) -# CHECK-NEXT: Flags [ (0x3) -# CHECK-NEXT: SHF_ALLOC (0x2) -# CHECK-NEXT: SHF_WRITE (0x1) -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x10020040 -# CHECK-NEXT: Offset: 0x20040 -# CHECK-NEXT: Size: 24 -# CHECK-NEXT: Link: 0 -# CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 -# CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 00000000 10010000 00000000 10038000 |................| -# CHECK-NEXT: 0010: 00000000 00000000 |........| -# CHECK-NEXT: ) -# CHECK-NEXT: } -# CHECK-NEXT: Section { -# CHECK-NEXT: Index: 5 -# CHECK-NEXT: Name: .got -# CHECK-NEXT: Type: SHT_PROGBITS -# CHECK-NEXT: Flags [ -# CHECK-NEXT: SHF_ALLOC -# CHECK-NEXT: SHF_WRITE -# CHECK-NEXT: ] -# CHECK-NEXT: Address: 0x10030000 -# CHECK-NEXT: Offset: 0x30000 -# CHECK-NEXT: Size: 0 -# CHECK-NEXT: Link: 0 -# CHECK-NEXT: Info: 0 -# CHECK-NEXT: AddressAlignment: 8 -# CHECK-NEXT: EntrySize: 0 -# CHECK-NEXT: SectionData ( -# CHECK-NEXT: ) -# CHECK-NEXT: } -# CHECK-NEXT: Section { -# CHECK-NEXT: Index: 6 -# CHECK-NEXT: Name: .comment +# CHECK-NEXT: Index: 2 +# CHECK-NEXT: Name: .comment (7) # CHECK-NEXT: Type: SHT_PROGBITS (0x1) # CHECK-NEXT: Flags [ (0x30) # CHECK-NEXT: SHF_MERGE (0x10) # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x30000 +# CHECK-NEXT: Offset: 0x11000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 # CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.| +# CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.| # CHECK-NEXT: ) # CHECK-NEXT: } # CHECK-NEXT: Section { -# CHECK-NEXT: Index: 7 -# CHECK-NEXT: Name: .symtab +# CHECK-NEXT: Index: 3 +# CHECK-NEXT: Name: .symtab (16) # CHECK-NEXT: Type: SHT_SYMTAB (0x2) # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x30008 -# CHECK-NEXT: Size: 48 -# CHECK-NEXT: Link: 9 +# CHECK-NEXT: Offset: 0x11008 +# CHECK-NEXT: Size: 24 +# CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 # CHECK-NEXT: AddressAlignment: 8 # CHECK-NEXT: EntrySize: 24 # CHECK-NEXT: SectionData ( -# CHECK: ) +# CHECK-NEXT: 0000: 00000000 00000000 00000000 00000000 |................| +# CHECK-NEXT: 0010: 00000000 00000000 |........| +# CHECK-NEXT: ) # CHECK-NEXT: } # CHECK-NEXT: Section { -# CHECK-NEXT: Index: 8 -# CHECK-NEXT: Name: .shstrtab -# CHECK-NEXT: Type: SHT_STRTAB -# CHECK-NEXT: Flags [ +# CHECK-NEXT: Index: 4 +# CHECK-NEXT: Name: .shstrtab (24) +# CHECK-NEXT: Type: SHT_STRTAB (0x3) +# CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x30038 -# CHECK-NEXT: Size: 63 +# CHECK-NEXT: Offset: 0x11020 +# CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 # CHECK-NEXT: EntrySize: 0 # CHECK-NEXT: SectionData ( -# CHECK: ) +# CHECK-NEXT: 0000: 002E7465 7874002E 636F6D6D 656E7400 |..text..comment.| +# CHECK-NEXT: 0010: 2E73796D 74616200 2E736873 74727461 |.symtab..shstrta| +# CHECK-NEXT: 0020: 62002E73 74727461 6200 |b..strtab.| +# CHECK-NEXT: ) # CHECK-NEXT: } # CHECK-NEXT: Section { -# CHECK-NEXT: Index: 9 -# CHECK-NEXT: Name: .strtab -# CHECK-NEXT: Type: SHT_STRTAB +# CHECK-NEXT: Index: 5 +# CHECK-NEXT: Name: .strtab (34) +# CHECK-NEXT: Type: SHT_STRTAB (0x3) # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x30077 -# CHECK-NEXT: Size: 8 +# CHECK-NEXT: Offset: 0x1104A +# CHECK-NEXT: Size: 1 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 # CHECK-NEXT: EntrySize: 0 # CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 005F7374 61727400 |._start.| +# CHECK-NEXT: 0000: 00 |.| # CHECK-NEXT: ) # CHECK-NEXT: } # CHECK-NEXT: ] @@ -237,74 +150,49 @@ # CHECK-NEXT: Offset: 0x40 # CHECK-NEXT: VirtualAddress: 0x10000040 # CHECK-NEXT: PhysicalAddress: 0x10000040 -# CHECK-NEXT: FileSize: 336 -# CHECK-NEXT: MemSize: 336 -# CHECK-NEXT: Flags [ -# CHECK-NEXT: PF_R +# CHECK-NEXT: FileSize: 224 +# CHECK-NEXT: MemSize: 224 +# CHECK-NEXT: Flags [ (0x4) +# CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: ] # CHECK-NEXT: Alignment: 8 # CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_LOAD (0x1) -# CHECK-NEXT: Offset: 0x0 -# CHECK-NEXT: VirtualAddress: 0x10000000 -# CHECK-NEXT: PhysicalAddress: 0x10000000 -# CHECK-NEXT: FileSize: 400 -# CHECK-NEXT: MemSize: 400 -# CHECK-NEXT: Flags [ -# CHECK-NEXT: PF_R -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: 65536 -# CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_LOAD (0x1) -# CHECK-NEXT: Offset: 0x10000 -# CHECK-NEXT: VirtualAddress: 0x10010000 -# CHECK-NEXT: PhysicalAddress: 0x10010000 -# CHECK-NEXT: FileSize: 12 -# CHECK-NEXT: MemSize: 12 -# CHECK-NEXT: Flags [ (0x5) -# CHECK-NEXT: PF_R (0x4) -# CHECK-NEXT: PF_X (0x1) -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: 65536 -# CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_LOAD (0x1) -# CHECK-NEXT: Offset: 0x20000 -# CHECK-NEXT: VirtualAddress: 0x10020000 -# CHECK-NEXT: PhysicalAddress: 0x10020000 -# CHECK-NEXT: FileSize: 65536 -# CHECK-NEXT: MemSize: 65536 -# CHECK-NEXT: Flags [ (0x6) -# CHECK-NEXT: PF_R (0x4) -# CHECK-NEXT: PF_W (0x2) -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: 65536 -# CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_GNU_RELRO -# CHECK-NEXT: Offset: 0x30000 -# CHECK-NEXT: VirtualAddress: 0x10030000 -# CHECK-NEXT: PhysicalAddress: 0x10030000 -# CHECK-NEXT: FileSize: 0 -# CHECK-NEXT: MemSize: 0 -# CHECK-NEXT: Flags [ (0x4) -# CHECK-NEXT: PF_R (0x4) -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: 1 -# CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_GNU_STACK (0x6474E551) -# CHECK-NEXT: Offset: 0x0 -# CHECK-NEXT: VirtualAddress: 0x0 -# CHECK-NEXT: PhysicalAddress: 0x0 -# CHECK-NEXT: FileSize: 0 -# CHECK-NEXT: MemSize: 0 -# CHECK-NEXT: Flags [ (0x6) -# CHECK-NEXT: PF_R (0x4) -# CHECK-NEXT: PF_W (0x2) -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: 0 -# CHECK-NEXT: } +# CHECK-NEXT: ProgramHeader { +# CHECK-NEXT: Type: PT_LOAD (0x1) +# CHECK-NEXT: Offset: 0x0 +# CHECK-NEXT: VirtualAddress: 0x10000000 +# CHECK-NEXT: PhysicalAddress: 0x10000000 +# CHECK-NEXT: FileSize: 288 +# CHECK-NEXT: MemSize: 288 +# CHECK-NEXT: Flags [ (0x4) +# CHECK-NEXT: PF_R (0x4) +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: 65536 +# CHECK-NEXT: } +# CHECK-NEXT: ProgramHeader { +# CHECK-NEXT: Type: PT_LOAD (0x1) +# CHECK-NEXT: Offset: 0x10000 +# CHECK-NEXT: VirtualAddress: 0x10010000 +# CHECK-NEXT: PhysicalAddress: 0x10010000 +# CHECK-NEXT: FileSize: 4096 +# CHECK-NEXT: MemSize: 4096 +# CHECK-NEXT: Flags [ (0x5) +# CHECK-NEXT: PF_R (0x4) +# CHECK-NEXT: PF_X (0x1) +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: 65536 +# CHECK-NEXT: } +# CHECK-NEXT: ProgramHeader { +# CHECK-NEXT: Type: PT_GNU_STACK (0x6474E551) +# CHECK-NEXT: Offset: 0x0 +# CHECK-NEXT: VirtualAddress: 0x0 +# CHECK-NEXT: PhysicalAddress: 0x0 +# CHECK-NEXT: FileSize: 0 +# CHECK-NEXT: MemSize: 0 +# CHECK-NEXT: Flags [ (0x6) +# CHECK-NEXT: PF_R (0x4) +# CHECK-NEXT: PF_W (0x2) +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: 0 +# CHECK-NEXT: } # CHECK-NEXT: ] Index: lld/test/ELF/emulation.s =================================================================== --- lld/test/ELF/emulation.s +++ lld/test/ELF/emulation.s @@ -208,8 +208,8 @@ # PPC64-NEXT: Entry: # PPC64-NEXT: ProgramHeaderOffset: 0x40 # PPC64-NEXT: SectionHeaderOffset: -# PPC64-NEXT: Flags [ (0x1) -# PPC64-NEXT: 0x1 +# PPC64-NEXT: Flags [ (0x2) +# PPC64-NEXT: 0x2 # PPC64-NEXT: ] # PPC64-NEXT: HeaderSize: 64 # PPC64-NEXT: ProgramHeaderEntrySize: 56 Index: lld/test/ELF/gnu-hash-table.s =================================================================== --- lld/test/ELF/gnu-hash-table.s +++ lld/test/ELF/gnu-hash-table.s @@ -4,30 +4,36 @@ # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %te.s -o %te-i386.o # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t-i386.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t-x86_64.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64-pc-linux %s -o %t-ppc64.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t-ppc64le.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t-ppc64.o # RUN: echo ".global zed; zed:" > %t2.s # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %t2.s -o %t2-i386.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2-x86_64.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64-pc-linux %t2.s -o %t2-ppc64.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %t2.s -o %t2-ppc64le.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %t2.s -o %t2-ppc64.o # RUN: rm -f %t2-i386.a %t2-x86_64.a %t2-ppc64.a # RUN: llvm-ar rc %t2-i386.a %t2-i386.o # RUN: llvm-ar rc %t2-x86_64.a %t2-x86_64.o +# RUN: llvm-ar rc %t2-ppc64le.a %t2-ppc64le.o # RUN: llvm-ar rc %t2-ppc64.a %t2-ppc64.o # RUN: echo ".global xyz; xyz:" > %t3.s # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %t3.s -o %t3-i386.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t3.s -o %t3-x86_64.o -# RUN: llvm-mc -filetype=obj -triple=powerpc64-pc-linux %t3.s -o %t3-ppc64.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %t3.s -o %t3-ppc64le.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %t3.s -o %t3-ppc64.o # RUN: ld.lld -shared %t3-i386.o -o %t3-i386.so # RUN: ld.lld -shared %t3-x86_64.o -o %t3-x86_64.so +# RUN: ld.lld -shared %t3-ppc64le.o -o %t3-ppc64le.so # RUN: ld.lld -shared %t3-ppc64.o -o %t3-ppc64.so # RUN: ld.lld -shared --hash-style=gnu -o %te-i386.so %te-i386.o # RUN: ld.lld -shared -hash-style=gnu -o %t-i386.so %t-i386.o %t2-i386.a %t3-i386.so # RUN: ld.lld -shared -hash-style=gnu -o %t-x86_64.so %t-x86_64.o %t2-x86_64.a %t3-x86_64.so +# RUN: ld.lld -shared --hash-style both -o %t-ppc64le.so %t-ppc64le.o %t2-ppc64le.a %t3-ppc64le.so # RUN: ld.lld -shared --hash-style both -o %t-ppc64.so %t-ppc64.o %t2-ppc64.a %t3-ppc64.so # RUN: llvm-readobj -dyn-symbols -gnu-hash-table %te-i386.so \ @@ -36,6 +42,8 @@ # RUN: | FileCheck %s -check-prefix=I386 # RUN: llvm-readobj -sections -dyn-symbols -gnu-hash-table %t-x86_64.so \ # RUN: | FileCheck %s -check-prefix=X86_64 +# RUN: llvm-readobj -sections -dyn-symbols -gnu-hash-table %t-ppc64le.so \ +# RUN: | FileCheck %s -check-prefix=PPC64 # RUN: llvm-readobj -sections -dyn-symbols -gnu-hash-table %t-ppc64.so \ # RUN: | FileCheck %s -check-prefix=PPC64 Index: lld/test/ELF/ppc64-addr16-error.s =================================================================== --- lld/test/ELF/ppc64-addr16-error.s +++ lld/test/ELF/ppc64-addr16-error.s @@ -1,3 +1,7 @@ +// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t +// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/ppc64-addr16-error.s -o %t2 +// RUN: not ld.lld -shared %t %t2 -o %t3 2>&1 | FileCheck %s + // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/ppc64-addr16-error.s -o %t2 // RUN: not ld.lld -shared %t %t2 -o %t3 2>&1 | FileCheck %s Index: lld/test/ELF/ppc64-rel-calls.s =================================================================== --- lld/test/ELF/ppc64-rel-calls.s +++ lld/test/ELF/ppc64-rel-calls.s @@ -1,32 +1,29 @@ +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 +# RUN: llvm-objdump -d %t2 | FileCheck %s + # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 # RUN: llvm-objdump -d %t2 | FileCheck %s + # REQUIRES: ppc # CHECK: Disassembly of section .text: -.section ".opd","aw" +.text .global _start _start: -.quad .Lfoo,.TOC.@tocbase,0 - -.text .Lfoo: li 0,1 li 3,42 sc -# CHECK: 10010000: 38 00 00 01 li 0, 1 -# CHECK: 10010004: 38 60 00 2a li 3, 42 -# CHECK: 10010008: 44 00 00 02 sc +# CHECK: 10010000: {{.*}} li 0, 1 +# CHECK: 10010004: {{.*}} li 3, 42 +# CHECK: 10010008: {{.*}} sc -.section ".opd","aw" .global bar bar: -.quad .Lbar,.TOC.@tocbase,0 - -.text -.Lbar: bl _start nop bl .Lfoo @@ -34,9 +31,8 @@ blr # FIXME: The printing here is misleading, the branch offset here is negative. -# CHECK: 1001000c: 4b ff ff f5 bl .+67108852 -# CHECK: 10010010: 60 00 00 00 nop -# CHECK: 10010014: 4b ff ff ed bl .+67108844 -# CHECK: 10010018: 60 00 00 00 nop -# CHECK: 1001001c: 4e 80 00 20 blr - +# CHECK: 1001000c: {{.*}} bl .+67108852 +# CHECK: 10010010: {{.*}} nop +# CHECK: 10010014: {{.*}} bl .+67108844 +# CHECK: 10010018: {{.*}} nop +# CHECK: 1001001c: {{.*}} blr Index: lld/test/ELF/ppc64-relocs.s =================================================================== --- lld/test/ELF/ppc64-relocs.s +++ lld/test/ELF/ppc64-relocs.s @@ -1,14 +1,16 @@ +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 +# RUN: llvm-objdump -d %t2 | FileCheck %s + # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 # RUN: llvm-objdump -d %t2 | FileCheck %s + # REQUIRES: ppc -.section ".opd","aw" +.text .global _start _start: -.quad .Lfoo,.TOC.@tocbase,0 - -.text .Lfoo: li 0,1 li 3,42 @@ -25,7 +27,7 @@ # CHECK: Disassembly of section .R_PPC64_TOC16_LO_DS: # CHECK: .FR_PPC64_TOC16_LO_DS: -# CHECK: 1001000c: e8 22 80 00 ld 1, -32768(2) +# CHECK: 1001000c: {{.*}} ld 1, -32768(2) .section .R_PPC64_TOC16_LO,"ax",@progbits .globl .FR_PPC64_TOC16_LO @@ -34,7 +36,7 @@ # CHECK: Disassembly of section .R_PPC64_TOC16_LO: # CHECK: .FR_PPC64_TOC16_LO: -# CHECK: 10010010: 38 22 80 00 addi 1, 2, -32768 +# CHECK: 10010010: {{.*}} addi 1, 2, -32768 .section .R_PPC64_TOC16_HI,"ax",@progbits .globl .FR_PPC64_TOC16_HI @@ -43,7 +45,7 @@ # CHECK: Disassembly of section .R_PPC64_TOC16_HI: # CHECK: .FR_PPC64_TOC16_HI: -# CHECK: 10010014: 3c 22 ff fe addis 1, 2, -2 +# CHECK: 10010014: {{.*}} addis 1, 2, -2 .section .R_PPC64_TOC16_HA,"ax",@progbits .globl .FR_PPC64_TOC16_HA @@ -52,7 +54,7 @@ # CHECK: Disassembly of section .R_PPC64_TOC16_HA: # CHECK: .FR_PPC64_TOC16_HA: -# CHECK: 10010018: 3c 22 ff ff addis 1, 2, -1 +# CHECK: 10010018: {{.*}} addis 1, 2, -1 .section .R_PPC64_REL24,"ax",@progbits .globl .FR_PPC64_REL24 @@ -63,7 +65,7 @@ # CHECK: Disassembly of section .R_PPC64_REL24: # CHECK: .FR_PPC64_REL24: -# CHECK: 1001001c: 48 00 00 04 b .+4 +# CHECK: 1001001c: {{.*}} b .+4 .section .R_PPC64_ADDR16_LO,"ax",@progbits .globl .FR_PPC64_ADDR16_LO @@ -72,7 +74,7 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_LO: # CHECK: .FR_PPC64_ADDR16_LO: -# CHECK: 10010020: 38 20 00 00 li 1, 0 +# CHECK: 10010020: {{.*}} li 1, 0 .section .R_PPC64_ADDR16_HI,"ax",@progbits .globl .FR_PPC64_ADDR16_HI @@ -81,7 +83,7 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_HI: # CHECK: .FR_PPC64_ADDR16_HI: -# CHECK: 10010024: 38 20 10 01 li 1, 4097 +# CHECK: 10010024: {{.*}} li 1, 4097 .section .R_PPC64_ADDR16_HA,"ax",@progbits .globl .FR_PPC64_ADDR16_HA @@ -90,7 +92,7 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_HA: # CHECK: .FR_PPC64_ADDR16_HA: -# CHECK: 10010028: 38 20 10 01 li 1, 4097 +# CHECK: 10010028: {{.*}} li 1, 4097 .section .R_PPC64_ADDR16_HIGHER,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHER @@ -99,7 +101,7 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHER: # CHECK: .FR_PPC64_ADDR16_HIGHER: -# CHECK: 1001002c: 38 20 00 00 li 1, 0 +# CHECK: 1001002c: {{.*}} li 1, 0 .section .R_PPC64_ADDR16_HIGHERA,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHERA @@ -108,7 +110,7 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHERA: # CHECK: .FR_PPC64_ADDR16_HIGHERA: -# CHECK: 10010030: 38 20 00 00 li 1, 0 +# CHECK: 10010030: {{.*}} li 1, 0 .section .R_PPC64_ADDR16_HIGHEST,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHEST @@ -117,7 +119,7 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHEST: # CHECK: .FR_PPC64_ADDR16_HIGHEST: -# CHECK: 10010034: 38 20 00 00 li 1, 0 +# CHECK: 10010034: {{.*}} li 1, 0 .section .R_PPC64_ADDR16_HIGHESTA,"ax",@progbits .globl .FR_PPC64_ADDR16_HIGHESTA @@ -126,5 +128,5 @@ # CHECK: Disassembly of section .R_PPC64_ADDR16_HIGHESTA: # CHECK: .FR_PPC64_ADDR16_HIGHESTA: -# CHECK: 10010038: 38 20 00 00 li 1, 0 +# CHECK: 10010038: {{.*}} li 1, 0 Index: lld/test/ELF/ppc64-shared-rel-toc.s =================================================================== --- lld/test/ELF/ppc64-shared-rel-toc.s +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t.so -// RUN: llvm-readobj -t -r -dyn-symbols %t.so | FileCheck %s -// REQUIRES: ppc - -// When we create the TOC reference in the shared library, make sure that the -// R_PPC64_RELATIVE relocation uses the correct (non-zero) offset. - - .globl foo - .align 2 - .type foo,@function - .section .opd,"aw",@progbits -foo: # @foo - .align 3 - .quad .Lfunc_begin0 - .quad .TOC.@tocbase - .quad 0 - .text -.Lfunc_begin0: - blr - -// CHECK: 0x20000 R_PPC64_RELATIVE - 0x10000 -// CHECK: 0x20008 R_PPC64_RELATIVE - 0x8000 - -// CHECK: Name: foo -// CHECK-NEXT: Value: 0x20000 - Index: lld/test/ELF/ppc64-weak-undef-call-shared.s =================================================================== --- lld/test/ELF/ppc64-weak-undef-call-shared.s +++ lld/test/ELF/ppc64-weak-undef-call-shared.s @@ -1,6 +1,11 @@ +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t.so +# RUN: llvm-readobj -t -r -dyn-symbols %t.so | FileCheck %s + # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o # RUN: ld.lld -shared %t.o -o %t.so # RUN: llvm-readobj -t -r -dyn-symbols %t.so | FileCheck %s + # REQUIRES: ppc .section ".toc","aw" Index: lld/test/ELF/ppc64-weak-undef-call.s =================================================================== --- lld/test/ELF/ppc64-weak-undef-call.s +++ lld/test/ELF/ppc64-weak-undef-call.s @@ -1,17 +1,18 @@ +# RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 +# RUN: llvm-objdump -d %t2 | FileCheck %s + # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 # RUN: llvm-objdump -d %t2 | FileCheck %s + # REQUIRES: ppc # CHECK: Disassembly of section .text: -.section ".opd","aw" +.text .global _start _start: -.quad .Lfoo,.TOC.@tocbase,0 - -.text -.Lfoo: bl weakfunc nop blr @@ -22,6 +23,6 @@ # be unreachable. But, we should link successfully. We should not, however, # generate a .plt entry (this would be wasted space). For now, we do nothing # (leaving the zero relative offset present in the input). -# CHECK: 10010000: 48 00 00 01 bl .+0 -# CHECK: 10010004: 60 00 00 00 nop -# CHECK: 10010008: 4e 80 00 20 blr +# CHECK: 10010000: {{.*}} bl .+0 +# CHECK: 10010004: {{.*}} nop +# CHECK: 10010008: {{.*}} blr Index: lld/test/ELF/relative-dynamic-reloc-ppc64.s =================================================================== --- lld/test/ELF/relative-dynamic-reloc-ppc64.s +++ lld/test/ELF/relative-dynamic-reloc-ppc64.s @@ -1,6 +1,11 @@ +// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o +// RUN: ld.lld -shared %t.o -o %t.so +// RUN: llvm-readobj -t -r -dyn-symbols %t.so | FileCheck %s + // RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o // RUN: ld.lld -shared %t.o -o %t.so // RUN: llvm-readobj -t -r -dyn-symbols %t.so | FileCheck %s + // REQUIRES: ppc // Test that we create R_PPC64_RELATIVE relocations but don't put any Index: lld/test/ELF/shared-be.s =================================================================== --- lld/test/ELF/shared-be.s +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o -// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld -dynamic-linker /lib64/ld64.so.1 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t -// RUN: llvm-readobj --dynamic-table -s %t | FileCheck %s -// REQUIRES: ppc - -// CHECK: Name: .rela.dyn -// CHECK-NEXT: Type: SHT_REL -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC -// CHECK-NEXT: ] -// CHECK-NEXT: Address: [[RELADDR:.*]] -// CHECK-NEXT: Offset: -// CHECK-NEXT: Size: [[RELSIZE:.*]] -// CHECK-NEXT: Link: -// CHECK-NEXT: Info: -// CHECK-NEXT: AddressAlignment: -// CHECK-NEXT: EntrySize: [[RELENT:.*]] - -// CHECK: DynamicSection [ -// CHECK-NEXT: Tag Type Name/Value -// CHECK-NEXT: 0x000000000000001D RUNPATH foo:bar -// CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: [{{.*}}2.so] -// CHECK-NEXT: 0x0000000000000015 DEBUG 0x0 -// CHECK-NEXT: 0x0000000000000007 RELA [[RELADDR]] -// CHECK-NEXT: 0x0000000000000008 RELASZ [[RELSIZE]] (bytes) -// CHECK-NEXT: 0x0000000000000009 RELAENT [[RELENT]] (bytes) -// CHECK: 0x0000000000000000 NULL 0x0 -// CHECK-NEXT: ] - -.global _start -_start: -.data -.long bar -.long zed - Index: lld/test/ELF/shared-ppc64.s =================================================================== --- /dev/null +++ lld/test/ELF/shared-ppc64.s @@ -0,0 +1,44 @@ +// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %p/Inputs/shared.s -o %t2.o +// RUN: ld.lld -shared %t2.o -o %t2.so +// RUN: ld.lld -dynamic-linker /lib64/ld64.so.1 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t +// RUN: llvm-readobj --dynamic-table -s %t | FileCheck %s + +// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %p/Inputs/shared.s -o %t2.o +// RUN: ld.lld -shared %t2.o -o %t2.so +// RUN: ld.lld -dynamic-linker /lib64/ld64.so.1 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t +// RUN: llvm-readobj --dynamic-table -s %t | FileCheck %s + +// REQUIRES: ppc + +// CHECK: Name: .rela.dyn +// CHECK-NEXT: Type: SHT_REL +// CHECK-NEXT: Flags [ +// CHECK-NEXT: SHF_ALLOC +// CHECK-NEXT: ] +// CHECK-NEXT: Address: [[RELADDR:.*]] +// CHECK-NEXT: Offset: +// CHECK-NEXT: Size: [[RELSIZE:.*]] +// CHECK-NEXT: Link: +// CHECK-NEXT: Info: +// CHECK-NEXT: AddressAlignment: +// CHECK-NEXT: EntrySize: [[RELENT:.*]] + +// CHECK: DynamicSection [ +// CHECK-NEXT: Tag Type Name/Value +// CHECK-NEXT: 0x000000000000001D RUNPATH foo:bar +// CHECK-NEXT: 0x0000000000000001 NEEDED Shared library: [{{.*}}2.so] +// CHECK-NEXT: 0x0000000000000015 DEBUG 0x0 +// CHECK-NEXT: 0x0000000000000007 RELA [[RELADDR]] +// CHECK-NEXT: 0x0000000000000008 RELASZ [[RELSIZE]] (bytes) +// CHECK-NEXT: 0x0000000000000009 RELAENT [[RELENT]] (bytes) +// CHECK: 0x0000000000000000 NULL 0x0 +// CHECK-NEXT: ] + +.global _start +_start: +.data +.long bar +.long zed +