ld: allow linking to a different offset
This commit is contained in:
parent
2ab6b4a5a9
commit
0e6a311610
@ -21,10 +21,10 @@ def parse_objs(objs):
|
|||||||
return sections, relocs
|
return sections, relocs
|
||||||
|
|
||||||
|
|
||||||
def map_sections(sections):
|
def map_sections(sections, offset=0):
|
||||||
secmap = []
|
secmap = []
|
||||||
|
|
||||||
addr = 0
|
addr = offset
|
||||||
|
|
||||||
# _start goes first
|
# _start goes first
|
||||||
for sec in sections:
|
for sec in sections:
|
||||||
@ -76,6 +76,8 @@ def parse_args():
|
|||||||
parser.add_argument('--output', '-o', type=argparse.FileType('wb'),
|
parser.add_argument('--output', '-o', type=argparse.FileType('wb'),
|
||||||
default=sys.stdout.buffer, help='output file')
|
default=sys.stdout.buffer, help='output file')
|
||||||
parser.add_argument('--vhdl', help='vhdl output with given template')
|
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()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +87,7 @@ def main():
|
|||||||
with open(CRT0_FILE, 'rb') as crt0:
|
with open(CRT0_FILE, 'rb') as crt0:
|
||||||
sections, relocs = parse_objs(args.objfiles + [crt0])
|
sections, relocs = parse_objs(args.objfiles + [crt0])
|
||||||
|
|
||||||
sectionmap = map_sections(sections)
|
sectionmap = map_sections(sections, offset=args.offset)
|
||||||
do_relocs(sectionmap, relocs)
|
do_relocs(sectionmap, relocs)
|
||||||
text = dump(sectionmap)
|
text = dump(sectionmap)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user