@@ -1164,14 +1164,11 @@ def libc_start_main_return(self):
1164
1164
to list all calls inside __libc_start_main, find the call to exit
1165
1165
after the call to main and select the previous call.
1166
1166
"""
1167
- if '__libc_start_main' not in self .functions :
1167
+ func = self .functions .get ('__libc_start_main' )
1168
+ exit_addr = self .symbols .get ('exit' )
1169
+ if not (func and exit_addr ):
1168
1170
return 0
1169
1171
1170
- if 'exit' not in self .symbols :
1171
- return 0
1172
-
1173
- func = self .functions ['__libc_start_main' ]
1174
- exit_addr = self .symbols ['exit' ]
1175
1172
# `__libc_start_call_main` is usually smaller than `__libc_start_main`,
1176
1173
# (except for powerpc which uses a bigger `generic_start_main`), so
1177
1174
# we might disassemble a bit too much, but it's a good dynamic estimate.
@@ -1184,9 +1181,8 @@ def libc_start_main_return(self):
1184
1181
call_return_offset = 1
1185
1182
call_instructions = set ([cs .CS_GRP_CALL ])
1186
1183
if self .arch in ['arm' , 'thumb' ]:
1187
- if b'armhf' in self .linker :
1188
- # FIXME: I have no idea why setting self.arch = 'armhf' does not work
1189
- eabi = 'hf'
1184
+ # FIXME: I have no idea why setting self.arch = 'armhf' does not work
1185
+ if b'armhf' in self .linker : eabi = 'hf'
1190
1186
if exit_addr & 1 : exit_addr -= 1
1191
1187
elif self .arch == 'aarch64' :
1192
1188
pass
@@ -1197,9 +1193,8 @@ def libc_start_main_return(self):
1197
1193
pass
1198
1194
elif self .arch in ['ppc' , 'powerpc' , 'powerpc64' ]:
1199
1195
callee_size *= 2
1200
- if exit_addr & 1 == 0 :
1201
- # powepc often jumps to the local entry point after TOC setup
1202
- exit_addr += 8
1196
+ # powepc often jumps to the local entry point after TOC setup
1197
+ if exit_addr & 1 == 0 : exit_addr += 8
1203
1198
pass
1204
1199
elif self .arch in ['em_s390' , 's390' ]:
1205
1200
imm_index = 1
0 commit comments