mirror of https://github.com/ARMmbed/mbed-os.git
feat: add support for .obj files in memap
parent
e03b3b68c1
commit
faac445b34
|
@ -104,10 +104,11 @@ class _Parser(object):
|
||||||
|
|
||||||
|
|
||||||
class _GccParser(_Parser):
|
class _GccParser(_Parser):
|
||||||
RE_OBJECT_FILE = re.compile(r'^(.+\/.+\.o)$')
|
RE_OBJECT_FILE = re.compile(r'^(.+\/.+\.o(bj)?)$')
|
||||||
RE_LIBRARY_OBJECT = re.compile(r'^.+' + r''.format(sep) + r'lib((.+\.a)\((.+\.o)\))$')
|
RE_LIBRARY_OBJECT = re.compile(r'^.+' + r''.format(sep) + r'lib((.+\.a)\((.+\.o(bj)?)\))$')
|
||||||
RE_STD_SECTION = re.compile(r'^\s+.*0x(\w{8,16})\s+0x(\w+)\s(.+)$')
|
RE_STD_SECTION = re.compile(r'^\s+.*0x(\w{8,16})\s+0x(\w+)\s(.+)$')
|
||||||
RE_FILL_SECTION = re.compile(r'^\s*\*fill\*\s+0x(\w{8,16})\s+0x(\w+).*$')
|
RE_FILL_SECTION = re.compile(r'^\s*\*fill\*\s+0x(\w{8,16})\s+0x(\w+).*$')
|
||||||
|
OBJECT_EXTENSIONS = (".o", ".obj")
|
||||||
|
|
||||||
ALL_SECTIONS = _Parser.SECTIONS + _Parser.OTHER_SECTIONS + \
|
ALL_SECTIONS = _Parser.SECTIONS + _Parser.OTHER_SECTIONS + \
|
||||||
_Parser.MISC_FLASH_SECTIONS + ('unknown', 'OUTPUT')
|
_Parser.MISC_FLASH_SECTIONS + ('unknown', 'OUTPUT')
|
||||||
|
@ -214,12 +215,12 @@ class _GccParser(_Parser):
|
||||||
self.module_add(object_name, object_size, current_section)
|
self.module_add(object_name, object_size, current_section)
|
||||||
|
|
||||||
common_prefix = dirname(commonprefix([
|
common_prefix = dirname(commonprefix([
|
||||||
o for o in self.modules.keys() if (o.endswith(".o") and not o.startswith("[lib]"))]))
|
o for o in self.modules.keys() if (o.endswith(self.OBJECT_EXTENSIONS) and not o.startswith("[lib]"))]))
|
||||||
new_modules = {}
|
new_modules = {}
|
||||||
for name, stats in self.modules.items():
|
for name, stats in self.modules.items():
|
||||||
if name.startswith("[lib]"):
|
if name.startswith("[lib]"):
|
||||||
new_modules[name] = stats
|
new_modules[name] = stats
|
||||||
elif name.endswith(".o"):
|
elif name.endswith(self.OBJECT_EXTENSIONS):
|
||||||
new_modules[relpath(name, common_prefix)] = stats
|
new_modules[relpath(name, common_prefix)] = stats
|
||||||
else:
|
else:
|
||||||
new_modules[name] = stats
|
new_modules[name] = stats
|
||||||
|
@ -229,7 +230,8 @@ class _GccParser(_Parser):
|
||||||
class _ArmccParser(_Parser):
|
class _ArmccParser(_Parser):
|
||||||
RE = re.compile(
|
RE = re.compile(
|
||||||
r'^\s+0x(\w{8})\s+0x(\w{8})\s+(\w+)\s+(\w+)\s+(\d+)\s+[*]?.+\s+(.+)$')
|
r'^\s+0x(\w{8})\s+0x(\w{8})\s+(\w+)\s+(\w+)\s+(\d+)\s+[*]?.+\s+(.+)$')
|
||||||
RE_OBJECT = re.compile(r'(.+\.(l|ar))\((.+\.o)\)')
|
RE_OBJECT = re.compile(r'(.+\.(l|ar))\((.+\.o(bj)?)\)')
|
||||||
|
OBJECT_EXTENSIONS = (".o", ".obj")
|
||||||
|
|
||||||
def parse_object_name(self, line):
|
def parse_object_name(self, line):
|
||||||
""" Parse object file
|
""" Parse object file
|
||||||
|
@ -237,7 +239,7 @@ class _ArmccParser(_Parser):
|
||||||
Positional arguments:
|
Positional arguments:
|
||||||
line - the line containing the object or library
|
line - the line containing the object or library
|
||||||
"""
|
"""
|
||||||
if line.endswith(".o"):
|
if line.endswith(self.OBJECT_EXTENSIONS):
|
||||||
return line
|
return line
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -305,12 +307,12 @@ class _ArmccParser(_Parser):
|
||||||
self.module_add(*self.parse_section(line))
|
self.module_add(*self.parse_section(line))
|
||||||
|
|
||||||
common_prefix = dirname(commonprefix([
|
common_prefix = dirname(commonprefix([
|
||||||
o for o in self.modules.keys() if (o.endswith(".o") and o != "anon$$obj.o" and not o.startswith("[lib]"))]))
|
o for o in self.modules.keys() if (o.endswith(self.OBJECT_EXTENSIONS) and o != "anon$$obj.o" and o != "anon$$obj.obj" and not o.startswith("[lib]"))]))
|
||||||
new_modules = {}
|
new_modules = {}
|
||||||
for name, stats in self.modules.items():
|
for name, stats in self.modules.items():
|
||||||
if name == "anon$$obj.o" or name.startswith("[lib]"):
|
if name == "anon$$obj.o" or name == "anon$$obj.obj" or name.startswith("[lib]"):
|
||||||
new_modules[name] = stats
|
new_modules[name] = stats
|
||||||
elif name.endswith(".o"):
|
elif name.endswith(self.OBJECT_EXTENSIONS):
|
||||||
new_modules[relpath(name, common_prefix)] = stats
|
new_modules[relpath(name, common_prefix)] = stats
|
||||||
else:
|
else:
|
||||||
new_modules[name] = stats
|
new_modules[name] = stats
|
||||||
|
@ -322,9 +324,10 @@ class _IarParser(_Parser):
|
||||||
r'^\s+(.+)\s+(zero|const|ro code|inited|uninit)\s'
|
r'^\s+(.+)\s+(zero|const|ro code|inited|uninit)\s'
|
||||||
r'+0x([\'\w]+)\s+0x(\w+)\s+(.+)\s.+$')
|
r'+0x([\'\w]+)\s+0x(\w+)\s+(.+)\s.+$')
|
||||||
|
|
||||||
RE_CMDLINE_FILE = re.compile(r'^#\s+(.+\.o)')
|
RE_CMDLINE_FILE = re.compile(r'^#\s+(.+\.o(bj)?)')
|
||||||
RE_LIBRARY = re.compile(r'^(.+\.a)\:.+$')
|
RE_LIBRARY = re.compile(r'^(.+\.a)\:.+$')
|
||||||
RE_OBJECT_LIBRARY = re.compile(r'^\s+(.+\.o)\s.*')
|
RE_OBJECT_LIBRARY = re.compile(r'^\s+(.+\.o(bj)?)\s.*')
|
||||||
|
OBJECT_EXTENSIONS = (".o", ".obj")
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
_Parser.__init__(self)
|
_Parser.__init__(self)
|
||||||
|
@ -338,7 +341,7 @@ class _IarParser(_Parser):
|
||||||
Positional arguments:
|
Positional arguments:
|
||||||
line - the line containing the object or library
|
line - the line containing the object or library
|
||||||
"""
|
"""
|
||||||
if object_name.endswith(".o"):
|
if object_name.endswith(self.OBJECT_EXTENSIONS):
|
||||||
try:
|
try:
|
||||||
return self.cmd_modules[object_name]
|
return self.cmd_modules[object_name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -432,7 +435,7 @@ class _IarParser(_Parser):
|
||||||
break
|
break
|
||||||
for arg in line.split(" "):
|
for arg in line.split(" "):
|
||||||
arg = arg.rstrip(" \n")
|
arg = arg.rstrip(" \n")
|
||||||
if (not arg.startswith("-")) and arg.endswith(".o"):
|
if (not arg.startswith("-")) and arg.endswith(self.OBJECT_EXTENSIONS):
|
||||||
self.cmd_modules[basename(arg)] = arg
|
self.cmd_modules[basename(arg)] = arg
|
||||||
|
|
||||||
common_prefix = dirname(commonprefix(list(self.cmd_modules.values())))
|
common_prefix = dirname(commonprefix(list(self.cmd_modules.values())))
|
||||||
|
|
Loading…
Reference in New Issue