mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-17 12:26:07 +00:00
[llvm-readobj] Fix bugs with unrecognized types in switch statements
Summary: Add missing breaks. Several functions used nested switch statements, where the outer switch branches based on the architecture, and the inner switch handles architecture-specific types. If the type isn't architecture-specific, break out to the generic types rather than fall through. getElfPtType: For GNU-style output, llvm-readobj prints "<unknown>: 0xnnnnnnnn" for an unrecognized segment type, unless the architecture is EM_ARM, EM_MIPS, or EM_MIPS_RS3_LE, in which case it prints "". This behavior appears accidental, so instead, always print the "<unknown>: 0xnnnnnnnn" string. Reviewers: pcc, grimar Reviewed By: grimar Subscribers: sdardis, javed.absar, arichardson, kristof.beyls, atanasyan, llvm-commits Differential Revision: https://reviews.llvm.org/D53730 llvm-svn: 345436
This commit is contained in:
parent
20d5a86793
commit
0c20b5be7c
@ -1194,6 +1194,7 @@ static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
|
||||
switch (Type) {
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_ARM_EXIDX);
|
||||
}
|
||||
break;
|
||||
case ELF::EM_MIPS:
|
||||
case ELF::EM_MIPS_RS3_LE:
|
||||
switch (Type) {
|
||||
@ -1202,6 +1203,7 @@ static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_OPTIONS);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_ABIFLAGS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (Type) {
|
||||
@ -1248,7 +1250,7 @@ static std::string getElfPtType(unsigned Arch, unsigned Type) {
|
||||
case ELF::EM_ARM:
|
||||
if (Type == ELF::PT_ARM_EXIDX)
|
||||
return "EXIDX";
|
||||
return "";
|
||||
break;
|
||||
case ELF::EM_MIPS:
|
||||
case ELF::EM_MIPS_RS3_LE:
|
||||
switch (Type) {
|
||||
@ -1261,7 +1263,7 @@ static std::string getElfPtType(unsigned Arch, unsigned Type) {
|
||||
case PT_MIPS_ABIFLAGS:
|
||||
return "ABIFLAGS";
|
||||
}
|
||||
return "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return std::string("<unknown>: ") + to_string(format_hex(Type, 1));
|
||||
@ -1638,29 +1640,32 @@ static const char *getTypeString(unsigned Arch, uint64_t Type) {
|
||||
case EM_HEXAGON:
|
||||
switch (Type) {
|
||||
#define HEXAGON_DYNAMIC_TAG(name, value) \
|
||||
case DT_##name: \
|
||||
return #name;
|
||||
case DT_##name: \
|
||||
return #name;
|
||||
#include "llvm/BinaryFormat/DynamicTags.def"
|
||||
#undef HEXAGON_DYNAMIC_TAG
|
||||
}
|
||||
break;
|
||||
|
||||
case EM_MIPS:
|
||||
switch (Type) {
|
||||
#define MIPS_DYNAMIC_TAG(name, value) \
|
||||
case DT_##name: \
|
||||
return #name;
|
||||
case DT_##name: \
|
||||
return #name;
|
||||
#include "llvm/BinaryFormat/DynamicTags.def"
|
||||
#undef MIPS_DYNAMIC_TAG
|
||||
}
|
||||
break;
|
||||
|
||||
case EM_PPC64:
|
||||
switch(Type) {
|
||||
case EM_PPC64:
|
||||
switch(Type) {
|
||||
#define PPC64_DYNAMIC_TAG(name, value) \
|
||||
case DT_##name: \
|
||||
return #name;
|
||||
#include "llvm/BinaryFormat/DynamicTags.def"
|
||||
#undef PPC64_DYNAMIC_TAG
|
||||
}
|
||||
break;
|
||||
}
|
||||
#undef DYNAMIC_TAG
|
||||
switch (Type) {
|
||||
@ -2829,11 +2834,13 @@ std::string getSectionTypeString(unsigned Arch, unsigned Type) {
|
||||
case SHT_ARM_OVERLAYSECTION:
|
||||
return "ARM_OVERLAYSECTION";
|
||||
}
|
||||
break;
|
||||
case EM_X86_64:
|
||||
switch (Type) {
|
||||
case SHT_X86_64_UNWIND:
|
||||
return "X86_64_UNWIND";
|
||||
}
|
||||
break;
|
||||
case EM_MIPS:
|
||||
case EM_MIPS_RS3_LE:
|
||||
switch (Type) {
|
||||
@ -2846,6 +2853,7 @@ std::string getSectionTypeString(unsigned Arch, unsigned Type) {
|
||||
case SHT_MIPS_DWARF:
|
||||
return "SHT_MIPS_DWARF";
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (Type) {
|
||||
case SHT_NULL:
|
||||
|
Loading…
x
Reference in New Issue
Block a user