mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
Remove bogus std::error_code returns form SectionRef.
There are two methods in SectionRef that can fail: * getName: The index into the string table can be invalid. * getContents: The section might point to invalid contents. Every other method will always succeed and returning and std::error_code just complicates the code. For example, a section can have an invalid alignment, but if we are able to get to the section structure at all and create a SectionRef, we will always be able to read that invalid alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -307,25 +307,17 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
}
|
||||
|
||||
for (const SectionRef &Section : Obj->sections()) {
|
||||
bool Text;
|
||||
if (error(Section.isText(Text)))
|
||||
break;
|
||||
bool Text = Section.isText();
|
||||
if (!Text)
|
||||
continue;
|
||||
|
||||
uint64_t SectionAddr;
|
||||
if (error(Section.getAddress(SectionAddr)))
|
||||
break;
|
||||
|
||||
uint64_t SectSize;
|
||||
if (error(Section.getSize(SectSize)))
|
||||
break;
|
||||
uint64_t SectionAddr = Section.getAddress();
|
||||
uint64_t SectSize = Section.getSize();
|
||||
|
||||
// Make a list of all the symbols in this section.
|
||||
std::vector<std::pair<uint64_t, StringRef>> Symbols;
|
||||
for (const SymbolRef &Symbol : Obj->symbols()) {
|
||||
bool contains;
|
||||
if (!error(Section.containsSymbol(Symbol, contains)) && contains) {
|
||||
if (Section.containsSymbol(Symbol)) {
|
||||
uint64_t Address;
|
||||
if (error(Symbol.getAddress(Address)))
|
||||
break;
|
||||
@ -501,19 +493,11 @@ static void PrintSectionHeaders(const ObjectFile *Obj) {
|
||||
StringRef Name;
|
||||
if (error(Section.getName(Name)))
|
||||
return;
|
||||
uint64_t Address;
|
||||
if (error(Section.getAddress(Address)))
|
||||
return;
|
||||
uint64_t Size;
|
||||
if (error(Section.getSize(Size)))
|
||||
return;
|
||||
bool Text, Data, BSS;
|
||||
if (error(Section.isText(Text)))
|
||||
return;
|
||||
if (error(Section.isData(Data)))
|
||||
return;
|
||||
if (error(Section.isBSS(BSS)))
|
||||
return;
|
||||
uint64_t Address = Section.getAddress();
|
||||
uint64_t Size = Section.getSize();
|
||||
bool Text = Section.isText();
|
||||
bool Data = Section.isData();
|
||||
bool BSS = Section.isBSS();
|
||||
std::string Type = (std::string(Text ? "TEXT " : "") +
|
||||
(Data ? "DATA " : "") + (BSS ? "BSS" : ""));
|
||||
outs() << format("%3d %-13s %08" PRIx64 " %016" PRIx64 " %s\n", i,
|
||||
@ -527,20 +511,14 @@ static void PrintSectionContents(const ObjectFile *Obj) {
|
||||
for (const SectionRef &Section : Obj->sections()) {
|
||||
StringRef Name;
|
||||
StringRef Contents;
|
||||
uint64_t BaseAddr;
|
||||
bool BSS;
|
||||
if (error(Section.getName(Name)))
|
||||
continue;
|
||||
if (error(Section.getAddress(BaseAddr)))
|
||||
continue;
|
||||
if (error(Section.isBSS(BSS)))
|
||||
continue;
|
||||
uint64_t BaseAddr = Section.getAddress();
|
||||
bool BSS = Section.isBSS();
|
||||
|
||||
outs() << "Contents of section " << Name << ":\n";
|
||||
if (BSS) {
|
||||
uint64_t Size;
|
||||
if (error(Section.getSize(Size)))
|
||||
continue;
|
||||
uint64_t Size = Section.getSize();
|
||||
outs() << format("<skipping contents of bss section at [%04" PRIx64
|
||||
", %04" PRIx64 ")>\n",
|
||||
BaseAddr, BaseAddr + Size);
|
||||
|
Reference in New Issue
Block a user