mirror of
https://github.com/zeldaret/oot.git
synced 2025-06-08 09:31:52 +00:00
fix_bss.py: Try to handle one-past-the-end pointers (#2471)
* fix_bss.py: Try to handle one-past-the-end pointers * Proofread
This commit is contained in:
parent
6f8b4d82d5
commit
a64fd8dea8
1 changed files with 8 additions and 8 deletions
|
@ -170,9 +170,9 @@ def get_file_pointers(
|
||||||
|
|
||||||
# For relocations against a global symbol, subtract the addend so that the pointer
|
# For relocations against a global symbol, subtract the addend so that the pointer
|
||||||
# is for the start of the symbol. This can help deal with things like STACK_TOP
|
# is for the start of the symbol. This can help deal with things like STACK_TOP
|
||||||
# (where the pointer is past the end of the symbol) or negative addends. If the
|
# (where the pointer is past the end of the symbol) or negative addends. We can't
|
||||||
# relocation is against a section however, it's not useful to subtract the addend,
|
# do this for relocations against a section though, since we need the addend to
|
||||||
# so we keep it as-is and hope for the best.
|
# distinguish between different static variables.
|
||||||
if reloc.name.startswith("."): # section
|
if reloc.name.startswith("."): # section
|
||||||
addend = reloc.addend
|
addend = reloc.addend
|
||||||
else: # symbol
|
else: # symbol
|
||||||
|
@ -446,13 +446,13 @@ def determine_base_bss_ordering(
|
||||||
new_symbol = None
|
new_symbol = None
|
||||||
new_offset = 0
|
new_offset = 0
|
||||||
for symbol in build_bss_symbols:
|
for symbol in build_bss_symbols:
|
||||||
if (
|
# To handle one-past-the-end pointers, we check <= instead of < for the symbol end.
|
||||||
symbol.offset <= build_offset
|
# This won't work if there is another symbol right after this one, since we'll
|
||||||
and build_offset < symbol.offset + symbol.size
|
# attribute this pointer to that symbol instead. This could prevent us from solving
|
||||||
):
|
# BSS ordering, but often the two symbols are adjacent in the baserom too so it works anyway.
|
||||||
|
if symbol.offset <= build_offset <= symbol.offset + symbol.size:
|
||||||
new_symbol = symbol
|
new_symbol = symbol
|
||||||
new_offset = base_offset - (build_offset - symbol.offset)
|
new_offset = base_offset - (build_offset - symbol.offset)
|
||||||
break
|
|
||||||
|
|
||||||
if new_symbol is None:
|
if new_symbol is None:
|
||||||
if p.addend > 0:
|
if p.addend > 0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue