|
@@ -360,6 +360,20 @@ class ELFFile:
|
|
|
self._fetch_symbols()
|
|
|
return self.symbols[sym]
|
|
|
|
|
|
+ def get_entry_point(self):
|
|
|
+ tool_readelf = "xtensa-lx106-elf-readelf"
|
|
|
+ if os.getenv('XTENSA_CORE')=='lx106':
|
|
|
+ tool_objcopy = "xt-readelf"
|
|
|
+ try:
|
|
|
+ proc = subprocess.Popen([tool_readelf, "-h", self.name], stdout=subprocess.PIPE)
|
|
|
+ except OSError:
|
|
|
+ print "Error calling "+tool_nm+", do you have Xtensa toolchain in PATH?"
|
|
|
+ sys.exit(1)
|
|
|
+ for l in proc.stdout:
|
|
|
+ fields = l.strip().split()
|
|
|
+ if fields[0] == "Entry":
|
|
|
+ return int(fields[3], 0);
|
|
|
+
|
|
|
def load_section(self, section):
|
|
|
tool_objcopy = "xtensa-lx106-elf-objcopy"
|
|
|
if os.getenv('XTENSA_CORE')=='lx106':
|
|
@@ -586,7 +600,7 @@ if __name__ == '__main__':
|
|
|
args.output = args.input + '-'
|
|
|
e = ELFFile(args.input)
|
|
|
image = ESPFirmwareImage()
|
|
|
- image.entrypoint = e.get_symbol_addr("call_user_start")
|
|
|
+ image.entrypoint = e.get_entry_point()
|
|
|
for section, start in ((".text", "_text_start"), (".data", "_data_start"), (".rodata", "_rodata_start")):
|
|
|
data = e.load_section(section)
|
|
|
image.add_segment(e.get_symbol_addr(start), data)
|