From 0e6a311610c2c27ca3c7a201aa988b19b6e8d55c Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Sat, 17 Apr 2021 23:05:02 -0700 Subject: [PATCH] ld: allow linking to a different offset --- tools/ld.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/ld.py b/tools/ld.py index 7e1f16f..7d9b2f4 100644 --- a/tools/ld.py +++ b/tools/ld.py @@ -21,10 +21,10 @@ def parse_objs(objs): return sections, relocs -def map_sections(sections): +def map_sections(sections, offset=0): secmap = [] - addr = 0 + addr = offset # _start goes first for sec in sections: @@ -76,6 +76,8 @@ def parse_args(): parser.add_argument('--output', '-o', type=argparse.FileType('wb'), default=sys.stdout.buffer, help='output file') parser.add_argument('--vhdl', help='vhdl output with given template') + parser.add_argument('--offset', default=0, type=int, + help='memory offset to link from') return parser.parse_args() @@ -85,7 +87,7 @@ def main(): with open(CRT0_FILE, 'rb') as crt0: sections, relocs = parse_objs(args.objfiles + [crt0]) - sectionmap = map_sections(sections) + sectionmap = map_sections(sections, offset=args.offset) do_relocs(sectionmap, relocs) text = dump(sectionmap)