Index: llvm/lib/Object/ELF.cpp =================================================================== --- llvm/lib/Object/ELF.cpp +++ llvm/lib/Object/ELF.cpp @@ -438,6 +438,7 @@ #include "llvm/BinaryFormat/DynamicTags.def" #undef HEXAGON_DYNAMIC_TAG } + break; case ELF::EM_MIPS: switch (Type) { @@ -445,6 +446,7 @@ #include "llvm/BinaryFormat/DynamicTags.def" #undef MIPS_DYNAMIC_TAG } + break; case ELF::EM_PPC64: switch (Type) { @@ -452,6 +454,7 @@ #include "llvm/BinaryFormat/DynamicTags.def" #undef PPC64_DYNAMIC_TAG } + break; } #undef DYNAMIC_TAG switch (Type) { Index: llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp =================================================================== --- llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp +++ llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp @@ -113,6 +113,7 @@ case RT64_8: return IsPCRel ? ELF::R_X86_64_PC8 : ELF::R_X86_64_8; } + llvm_unreachable("unexpected relocation type!"); case MCSymbolRefExpr::VK_GOT: switch (Type) { case RT64_64: @@ -124,6 +125,7 @@ case RT64_8: llvm_unreachable("Unimplemented"); } + llvm_unreachable("unexpected relocation type!"); case MCSymbolRefExpr::VK_GOTOFF: assert(Type == RT64_64); assert(!IsPCRel); @@ -140,6 +142,7 @@ case RT64_8: llvm_unreachable("Unimplemented"); } + llvm_unreachable("unexpected relocation type!"); case MCSymbolRefExpr::VK_DTPOFF: assert(!IsPCRel); switch (Type) { @@ -152,6 +155,7 @@ case RT64_8: llvm_unreachable("Unimplemented"); } + llvm_unreachable("unexpected relocation type!"); case MCSymbolRefExpr::VK_SIZE: assert(!IsPCRel); switch (Type) { @@ -164,6 +168,7 @@ case RT64_8: llvm_unreachable("Unimplemented"); } + llvm_unreachable("unexpected relocation type!"); case MCSymbolRefExpr::VK_TLSCALL: return ELF::R_X86_64_TLSDESC_CALL; case MCSymbolRefExpr::VK_TLSDESC: @@ -196,6 +201,7 @@ case X86::reloc_riprel_4byte_movq_load: return ELF::R_X86_64_REX_GOTPCRELX; } + llvm_unreachable("unexpected relocation type!"); } } @@ -233,6 +239,7 @@ case RT32_8: return IsPCRel ? ELF::R_386_PC8 : ELF::R_386_8; } + llvm_unreachable("unexpected relocation type!"); case MCSymbolRefExpr::VK_GOT: assert(Type == RT32_32); if (IsPCRel) Index: llvm/test/tools/llvm-objdump/elf-dynamic-section-machine-specific.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-objdump/elf-dynamic-section-machine-specific.test @@ -0,0 +1,269 @@ +# Test that hexagon machine-specific tags can be dumped. +# RUN: yaml2obj --docnum=1 %s -o %t.hex +# RUN: llvm-objdump -p %t.hex | FileCheck %s --check-prefix=HEXAGON + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_HEXAGON +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Address: 0x1000 + Size: 0x10 + Content: "004400550066007700" + - Name: .dynamic + Type: SHT_DYNAMIC + Address: 0x1010 + Entries: + - Tag: DT_HASH + Value: 0x1000 + - Tag: DT_HEXAGON_SYMSZ + Value: 0x10 + - Tag: DT_HEXAGON_VER + Value: 0x1000 + - Tag: DT_HEXAGON_PLT + Value: 0x1000 + - Tag: 0x1234abcd + Value: 0x1 + - Tag: DT_NULL + Value: 0 +ProgramHeaders: + - Type: PT_LOAD + VAddr: 0x1000 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + Sections: + - Section: .dynamic + +# HEXAGON: Dynamic Section: +# HEXAGON-NEXT: HASH 0x0000000000001000 +# HEXAGON-NEXT: HEXAGON_SYMSZ 0x0000000000000010 +# HEXAGON-NEXT: HEXAGON_VER 0x0000000000001000 +# HEXAGON-NEXT: HEXAGON_PLT 0x0000000000001000 +# HEXAGON-NEXT: 0x1234abcd 0x0000000000000001 + +# Test that MIPS machine-specific tags can be dumped. +# RUN: yaml2obj --docnum=2 %s -o %t.mips +# RUN: llvm-objdump -p %t.mips | FileCheck %s --check-prefix=MIPS + +# MIPS: Dynamic Section: +# MIPS-NEXT: HASH 0x0000000000001000 +# MIPS-NEXT: MIPS_RLD_VERSION 0x0000000012345678 +# MIPS-NEXT: MIPS_TIME_STAMP 0x0000000011223344 +# MIPS-NEXT: MIPS_ICHECKSUM 0x0000000011112222 +# MIPS-NEXT: MIPS_IVERSION 0x0000000000000001 +# MIPS-NEXT: MIPS_FLAGS 0x0000000011111111 +# MIPS-NEXT: MIPS_BASE_ADDRESS 0x0000000087654321 +# MIPS-NEXT: MIPS_MSYM 0x0000000000001000 +# MIPS-NEXT: MIPS_CONFLICT 0x0000000000001000 +# MIPS-NEXT: MIPS_LIBLIST 0x0000000000001000 +# MIPS-NEXT: MIPS_LOCAL_GOTNO 0x0000000000000001 +# MIPS-NEXT: MIPS_CONFLICTNO 0x0000000000000001 +# MIPS-NEXT: MIPS_LIBLISTNO 0x0000000000000001 +# MIPS-NEXT: MIPS_SYMTABNO 0x0000000000000001 +# MIPS-NEXT: MIPS_UNREFEXTNO 0x0000000000000000 +# MIPS-NEXT: MIPS_GOTSYM 0x0000000000000000 +# MIPS-NEXT: MIPS_HIPAGENO 0x0000000088776655 +# MIPS-NEXT: MIPS_RLD_MAP 0x0000000000001000 +# MIPS-NEXT: MIPS_DELTA_CLASS 0x0000000000001000 +# MIPS-NEXT: MIPS_DELTA_CLASS_NO 0x0000000000000001 +# MIPS-NEXT: MIPS_DELTA_INSTANCE 0x0000000000001000 +# MIPS-NEXT: MIPS_DELTA_INSTANCE_NO0x0000000000000001 +# MIPS-NEXT: MIPS_DELTA_RELOC 0x0000000000001000 +# MIPS-NEXT: MIPS_DELTA_RELOC_NO 0x0000000000000001 +# MIPS-NEXT: MIPS_DELTA_SYM 0x0000000000001000 +# MIPS-NEXT: MIPS_DELTA_SYM_NO 0x0000000000000001 +# MIPS-NEXT: MIPS_DELTA_CLASSSYM 0x0000000000001000 +# MIPS-NEXT: MIPS_DELTA_CLASSSYM_NO0x0000000000000001 +# MIPS-NEXT: MIPS_CXX_FLAGS 0x0000000088887777 +# MIPS-NEXT: MIPS_PIXIE_INIT 0x0000000000001000 +# MIPS-NEXT: MIPS_LOCALPAGE_GOTIDX0x0000000000000001 +# MIPS-NEXT: MIPS_LOCAL_GOTIDX 0x0000000000000001 +# MIPS-NEXT: MIPS_HIDDEN_GOTIDX 0x0000000000000001 +# MIPS-NEXT: MIPS_PROTECTED_GOTIDX0x0000000000000001 +# MIPS-NEXT: MIPS_OPTIONS 0x0000000000001000 +# MIPS-NEXT: MIPS_INTERFACE 0x0000000000001000 +# MIPS-NEXT: MIPS_DYNSTR_ALIGN 0x0000000088888888 +# MIPS-NEXT: MIPS_INTERFACE_SIZE 0x0000000000000010 +# MIPS-NEXT: MIPS_RLD_TEXT_RESOLVE_ADDR0x0000000000000008 +# MIPS-NEXT: MIPS_PERF_SUFFIX 0x0000000000000000 +# MIPS-NEXT: MIPS_COMPACT_SIZE 0x0000000000000010 +# MIPS-NEXT: MIPS_GP_VALUE 0x0000000000000001 +# MIPS-NEXT: MIPS_AUX_DYNAMIC 0x0000000000001000 +# MIPS-NEXT: MIPS_PLTGOT 0x0000000000001000 +# MIPS-NEXT: MIPS_RWPLT 0x0000000000001000 +# MIPS-NEXT: MIPS_RLD_MAP_REL 0x0000000000001000 +# MIPS-NEXT: 0x1234abcd 0x0000000000000001 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_MIPS +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Address: 0x1000 + Size: 0x10 + Content: "004400550066007700" + - Name: .dynamic + Type: SHT_DYNAMIC + Address: 0x1010 + Entries: + - Tag: DT_HASH + Value: 0x1000 + - Tag: DT_MIPS_RLD_VERSION + Value: 0x12345678 + - Tag: DT_MIPS_TIME_STAMP + Value: 0x11223344 + - Tag: DT_MIPS_ICHECKSUM + Value: 0x11112222 + - Tag: DT_MIPS_IVERSION + Value: 0x1 + - Tag: DT_MIPS_FLAGS + Value: 0x11111111 + - Tag: DT_MIPS_BASE_ADDRESS + Value: 0x87654321 + - Tag: DT_MIPS_MSYM + Value: 0x1000 + - Tag: DT_MIPS_CONFLICT + Value: 0x1000 + - Tag: DT_MIPS_LIBLIST + Value: 0x1000 + - Tag: DT_MIPS_LOCAL_GOTNO + Value: 0x1 + - Tag: DT_MIPS_CONFLICTNO + Value: 0x1 + - Tag: DT_MIPS_LIBLISTNO + Value: 0x1 + - Tag: DT_MIPS_SYMTABNO + Value: 0x1 + - Tag: DT_MIPS_UNREFEXTNO + Value: 0x0 + - Tag: DT_MIPS_GOTSYM + Value: 0x0 + - Tag: DT_MIPS_HIPAGENO + Value: 0x88776655 + - Tag: DT_MIPS_RLD_MAP + Value: 0x1000 + - Tag: DT_MIPS_DELTA_CLASS + Value: 0x1000 + - Tag: DT_MIPS_DELTA_CLASS_NO + Value: 0x1 + - Tag: DT_MIPS_DELTA_INSTANCE + Value: 0x1000 + - Tag: DT_MIPS_DELTA_INSTANCE_NO + Value: 0x1 + - Tag: DT_MIPS_DELTA_RELOC + Value: 0x1000 + - Tag: DT_MIPS_DELTA_RELOC_NO + Value: 0x1 + - Tag: DT_MIPS_DELTA_SYM + Value: 0x1000 + - Tag: DT_MIPS_DELTA_SYM_NO + Value: 0x1 + - Tag: DT_MIPS_DELTA_CLASSSYM + Value: 0x1000 + - Tag: DT_MIPS_DELTA_CLASSSYM_NO + Value: 0x1 + - Tag: DT_MIPS_CXX_FLAGS + Value: 0x88887777 + - Tag: DT_MIPS_PIXIE_INIT + Value: 0x1000 + - Tag: DT_MIPS_LOCALPAGE_GOTIDX + Value: 0x1 + - Tag: DT_MIPS_LOCAL_GOTIDX + Value: 0x1 + - Tag: DT_MIPS_HIDDEN_GOTIDX + Value: 0x1 + - Tag: DT_MIPS_PROTECTED_GOTIDX + Value: 0x1 + - Tag: DT_MIPS_OPTIONS + Value: 0x1000 + - Tag: DT_MIPS_INTERFACE + Value: 0x1000 + - Tag: DT_MIPS_DYNSTR_ALIGN + Value: 0x88888888 + - Tag: DT_MIPS_INTERFACE_SIZE + Value: 0x10 + - Tag: DT_MIPS_RLD_TEXT_RESOLVE_ADDR + Value: 0x8 + - Tag: DT_MIPS_PERF_SUFFIX + Value: 0x0 + - Tag: DT_MIPS_COMPACT_SIZE + Value: 0x10 + - Tag: DT_MIPS_GP_VALUE + Value: 0x1 + - Tag: DT_MIPS_AUX_DYNAMIC + Value: 0x1000 + - Tag: DT_MIPS_PLTGOT + Value: 0x1000 + - Tag: DT_MIPS_RWPLT + Value: 0x1000 + - Tag: DT_MIPS_RLD_MAP_REL + Value: 0x1000 + - Tag: 0x1234abcd + Value: 0x1 + - Tag: DT_NULL + Value: 0 +ProgramHeaders: + - Type: PT_LOAD + VAddr: 0x1000 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + Sections: + - Section: .dynamic + +# Test that PPC64 machine-specific tags can be dumped. +# RUN: yaml2obj --docnum=3 %s -o %t.ppc +# RUN: llvm-objdump -p %t.ppc | FileCheck %s --check-prefix=PPC + +# PPC: Dynamic Section: +# PPC-NEXT: HASH 0x0000000000001000 +# PPC-NEXT: PPC64_GLINK 0x0000000000001000 +# PPC-NEXT: 0x1234abcd 0x0000000000000001 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_PPC64 +Sections: + - Name: .dynstr + Type: SHT_STRTAB + Address: 0x1000 + Size: 0x10 + Content: "004400550066007700" + - Name: .dynamic + Type: SHT_DYNAMIC + Address: 0x1010 + Entries: + - Tag: DT_HASH + Value: 0x1000 + - Tag: DT_PPC64_GLINK + Value: 0x1000 + - Tag: 0x1234abcd + Value: 0x1 + - Tag: DT_NULL + Value: 0 +ProgramHeaders: + - Type: PT_LOAD + VAddr: 0x1000 + Sections: + - Section: .dynstr + - Section: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x1010 + Sections: + - Section: .dynamic