1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-05-12 12:00:14 +00:00

Derive objcopy arguments from GNU ld output

This commit is contained in:
Thomas Fitzsimmons 2023-02-28 21:37:09 -05:00
parent 60e3bc4581
commit 7ad1aac065
3 changed files with 24 additions and 7 deletions

View file

@ -1 +0,0 @@
objcopy -Ibinary -Oelf32-i386 -Bi386

View file

@ -1,3 +0,0 @@
objcopy -Ibinary -Oelf64-x86-64 -Bi386:x86-64

View file

@ -13123,9 +13123,30 @@ IF os$ = "LNX" THEN
IF inline_DATA = 0 THEN
IF DataOffset THEN
IF INSTR(_OS$, "[32BIT]") THEN b$ = "32" ELSE b$ = "64"
OPEN ".\internal\c\makedat_lnx" + b$ + ".txt" FOR BINARY AS #150: LINE INPUT #150, a$: CLOSE #150
a$ = a$ + " " + tmpdir2$ + "data.bin " + tmpdir2$ + "data.o"
SHELL _HIDE "ld --verbose >internal/temp/ld-output.txt"
OPEN "internal/temp/ld-output.txt" FOR BINARY AS #150
DO UNTIL EOF(150)
LINE INPUT #150, a$
IF LEN(a$) THEN
s$ = "OUTPUT_FORMAT(" + CHR$(34)
x1 = INSTR(a$, s$)
IF x1 THEN
x1 = x1 + LEN(s$)
x2 = INSTR(x1, a$, CHR$(34))
format$ = MID$(a$, x1, x2 - x1)
ELSE
s$ = "OUTPUT_ARCH("
x1 = INSTR(a$, s$)
IF x1 THEN
x1 = x1 + LEN(s$)
x2 = INSTR(x1, a$, ")")
architecture$ = MID$(a$, x1, x2 - x1)
END IF
END IF
END IF
LOOP
CLOSE #150
a$ = "objcopy -Ibinary -O" + format$ + " -B" + architecture$ + " " + tmpdir2$ + "data.bin " + tmpdir2$ + "data.o"
CHDIR ".\internal\c"
SHELL _HIDE a$ + " 2>> ../../" + compilelog$
CHDIR "..\.."