Skip to content

Commit

Permalink
fix: allow ignore some symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed May 23, 2024
1 parent 3a7a9b8 commit d95441e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion asm2asm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1858,6 +1858,7 @@ def _alloc_instr(self, instr: Instruction):
__instr_repl__ = {
'movdqa' : 'movdqu',
'movaps' : 'movups',
'movapd' : 'movupd',
'vmovdqa' : 'vmovdqu',
'vmovaps' : 'vmovups',
'vmovapd' : 'vmovupd',
Expand Down Expand Up @@ -2505,6 +2506,12 @@ def make_subr_filename(name: str) -> str:
else:
return '%s_subr_%s.go' % ('_'.join(base[:-1]), base[-1])


IGNORED_STUBS = {
"_do_xprintf",
"_write_syscall"
}

def main():
# check for arguments
if len(sys.argv) < 3:
Expand Down Expand Up @@ -2588,6 +2595,13 @@ def main():
print('import (\n\t`github.com/bytedance/sonic/loader`\n)', file = fp)
print(file = fp)
print('const (', file = fp)

# remove duplicated symbols
keys = list(asm.code.funcs.keys())
for name in keys:
if name in IGNORED_STUBS:
asm.code.funcs.pop(name)

for name in asm.code.funcs.keys():
addr = asm.code.get(name)
if addr is not None:
Expand Down Expand Up @@ -2626,7 +2640,7 @@ def main():
print('var _cfunc%s = []loader.CFunc{' % name, file = fp)
print(' {"%s_entry", 0, _entry_%s, 0, nil},' % (name, name), file = fp)
print(' {"%s", _entry_%s, _size_%s, _stack_%s, _pcsp_%s},' % (name, name, name, name, name), file = fp)
print('}', file = fp)
print('}', file = fp)

else:
print(file = fp)
Expand Down

0 comments on commit d95441e

Please sign in to comment.