mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-01 13:17:01 +00:00
Simplify the handling of iterators in ObjectFile.
None of the object file formats reported error on iterator increment. In retrospect, that is not too surprising: no object format stores symbols or sections in a linked list or other structure that requires chasing pointers. As a consequence, all error checking can be done on begin() and end(). This reduces the text segment of bin/llvm-readobj in my machine from 521233 to 518526 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200442 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -37,11 +37,8 @@ MCObjectDisassembler::MCObjectDisassembler(const ObjectFile &Obj,
|
||||
: Obj(Obj), Dis(Dis), MIA(MIA), MOS(0) {}
|
||||
|
||||
uint64_t MCObjectDisassembler::getEntrypoint() {
|
||||
error_code ec;
|
||||
for (symbol_iterator SI = Obj.begin_symbols(), SE = Obj.end_symbols();
|
||||
SI != SE; SI.increment(ec)) {
|
||||
if (ec)
|
||||
break;
|
||||
SI != SE; ++SI) {
|
||||
StringRef Name;
|
||||
SI->getName(Name);
|
||||
if (Name == "main" || Name == "_main") {
|
||||
@@ -90,13 +87,8 @@ MCModule *MCObjectDisassembler::buildModule(bool withCFG) {
|
||||
}
|
||||
|
||||
void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
|
||||
error_code ec;
|
||||
for (section_iterator SI = Obj.begin_sections(),
|
||||
SE = Obj.end_sections();
|
||||
SI != SE;
|
||||
SI.increment(ec)) {
|
||||
if (ec) break;
|
||||
|
||||
for (section_iterator SI = Obj.begin_sections(), SE = Obj.end_sections();
|
||||
SI != SE; ++SI) {
|
||||
bool isText; SI->isText(isText);
|
||||
bool isData; SI->isData(isData);
|
||||
if (!isData && !isText)
|
||||
@@ -184,11 +176,8 @@ void MCObjectDisassembler::buildCFG(MCModule *Module) {
|
||||
AddressSetTy Splits;
|
||||
AddressSetTy Calls;
|
||||
|
||||
error_code ec;
|
||||
for (symbol_iterator SI = Obj.begin_symbols(), SE = Obj.end_symbols();
|
||||
SI != SE; SI.increment(ec)) {
|
||||
if (ec)
|
||||
break;
|
||||
SI != SE; ++SI) {
|
||||
SymbolRef::Type SymType;
|
||||
SI->getType(SymType);
|
||||
if (SymType == SymbolRef::ST_Function) {
|
||||
@@ -506,11 +495,8 @@ MCMachOObjectDisassembler::MCMachOObjectDisassembler(
|
||||
: MCObjectDisassembler(MOOF, Dis, MIA), MOOF(MOOF),
|
||||
VMAddrSlide(VMAddrSlide), HeaderLoadAddress(HeaderLoadAddress) {
|
||||
|
||||
error_code ec;
|
||||
for (section_iterator SI = MOOF.begin_sections(), SE = MOOF.end_sections();
|
||||
SI != SE; SI.increment(ec)) {
|
||||
if (ec)
|
||||
break;
|
||||
SI != SE; ++SI) {
|
||||
StringRef Name;
|
||||
SI->getName(Name);
|
||||
// FIXME: We should use the S_ section type instead of the name.
|
||||
|
Reference in New Issue
Block a user