2018-05-21 04:31:06 +00:00
|
|
|
|
Set DEST "{1}"
|
|
|
|
|
Set DEST_X "{TempFolder}LinkedPowerROM.x"
|
2017-11-19 04:11:07 +00:00
|
|
|
|
Shift
|
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "Hello from LinkPowerROM, the 21st-century PowerMac ROM linker"
|
|
|
|
|
Echo "DEST = {DEST}"
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set CTOOL "{0}".tool
|
|
|
|
|
Echo "Assuming that {CTOOL} is compiled"
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set CurOffset 0 # contains a decimal number throughout
|
|
|
|
|
Set LinkList "" # contains space-separated quoted xcoff filenames
|
|
|
|
|
Set CksumOffset 0x30d000 # a good default
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "{#} arguments..."
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Loop
|
2017-11-19 04:11:07 +00:00
|
|
|
|
If !{#}
|
|
|
|
|
Break
|
|
|
|
|
End
|
2018-05-21 04:31:06 +00:00
|
|
|
|
|
|
|
|
|
Echo ------------------------------
|
|
|
|
|
Echo "ARG '{1}'"
|
|
|
|
|
|
2017-11-19 04:11:07 +00:00
|
|
|
|
If "{1}" =~ /[0-9]+/ || "{1}" =~ /0x[0-9a-f]+/
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "Move to offset."
|
|
|
|
|
Set NewOffset `Evaluate "{1}"`
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
If {NewOffset} <20>< {CurOffset}
|
|
|
|
|
Echo "{0} failed: cannot pad to offset {NewOffset} because we are already past it!" >> Dev:Stderr
|
2017-11-19 04:11:07 +00:00
|
|
|
|
Exit 1
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Else If {NewOffset} <20>> {CurOffset}
|
|
|
|
|
Set Delta `Evaluate {NewOffset} - {CurOffset}`
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set F "Zeros_{Delta}.s"
|
|
|
|
|
Echo "Create {F}"
|
|
|
|
|
Set F "{TempFolder}{F}"
|
|
|
|
|
Echo " DCB.B {Delta}, 0" > "{F}"
|
|
|
|
|
PPCAsm "{F}"
|
|
|
|
|
Set LinkList "{LinkList} '{F}.o'"
|
|
|
|
|
|
|
|
|
|
Set CurOffset {NewOffset}
|
2017-11-19 04:11:07 +00:00
|
|
|
|
End
|
2018-05-21 04:31:06 +00:00
|
|
|
|
|
2017-11-19 04:11:07 +00:00
|
|
|
|
Else If "{1}" =~ /([A-Za-z0-9]+)<29>1:/
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "Insert label for linker."
|
|
|
|
|
Set Label {<7B>1}
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set F "{TempFolder}Label_{Label}.s"
|
|
|
|
|
Echo " EXPORT {Label}" > "{F}"
|
|
|
|
|
Echo "{Label}:" >> "{F}"
|
|
|
|
|
PPCAsm "{F}"
|
|
|
|
|
Set LinkList "{LinkList} '{F}.o'"
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Else If "{1}" == CHECKSUM
|
|
|
|
|
Echo "Put the ConfigInfo checksum here."
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set CksumOffset {CurOffset}
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Else
|
|
|
|
|
Echo "Link this file."
|
|
|
|
|
Set F "{1}"
|
|
|
|
|
|
|
|
|
|
# Convert to an xcoff if necessary
|
|
|
|
|
If "{F}" !~ /<2F>.x/
|
|
|
|
|
Echo "Converting to xcoff first."
|
|
|
|
|
Set NewPath "`Echo {F} | StreamEdit -d -e '/(<28>:)*([<5B>:]*)<29>1/ print <20>1'`.x"
|
|
|
|
|
Echo "Temporary file {NewPath}"
|
|
|
|
|
Set NewPath "{TempFolder}{NewPath}"
|
|
|
|
|
"{CTOOL}" tox "{F}" "{NewPath}"
|
|
|
|
|
Set F "{NewPath}"
|
|
|
|
|
End
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set LinkList "{LinkList} '{F}'"
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Set TextLen `DumpXCOFF -do h "{F}" | StreamEdit -d -e '/s_nameŶ".(<28>)<29>1<EFBFBD>"/ Set CurSec <20>1' -e '/s_sizeŶ((<28>)<29>1<EFBFBD>)/ Print CurSec " " <20>1' | StreamEdit -d -e '/text (<28>)<29>1/ Print <20>1'`
|
|
|
|
|
Echo -n "File size = "; Evaluate -h {TextLen}
|
|
|
|
|
Set CurOffset `Evaluate {CurOffset} + {TextLen}`
|
|
|
|
|
End
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo -n "CurOffset = "; Evaluate -h {CurOffset}
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Shift
|
|
|
|
|
End
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo ------------------------------
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "Running PPCLink..."
|
2018-07-15 10:10:37 +00:00
|
|
|
|
PPCLink -xm library -dead off -codestart 0 -warn -o "{DEST_X}" {LinkList}
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "Dumping temp xcoff to DEST..."
|
|
|
|
|
"{CTOOL}" fromx "{DEST_X}" "{DEST}"
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "Checksumming DEST..."
|
|
|
|
|
"{CTOOL}" cksum "{DEST}" {CksumOffset}
|
2017-11-19 04:11:07 +00:00
|
|
|
|
|
2018-05-21 04:31:06 +00:00
|
|
|
|
Echo "All done."
|