Skip to content

Conversation

@lhames
Copy link

@lhames lhames commented Jul 20, 2020

…OR relocs.

When processing a MachO SUBTRACTOR/UNSIGNED pair, if the UNSIGNED target
is non-extern then check the r_symbolnum field of the relocation to find
the targeted section and use the section's address to find 'ToSymbol'.

Previously 'ToSymbol' was found by loading the initial value stored at
the fixup location and treating this as an address to search for. This
is incorrect, however: the initial value includes the addend and will
point to the wrong block if the addend is less than zero or greater than
the block size.

rdar://problem/65756694

…OR relocs.

When processing a MachO SUBTRACTOR/UNSIGNED pair, if the UNSIGNED target
is non-extern then check the r_symbolnum field of the relocation to find
the targeted section and use the section's address to find 'ToSymbol'.

Previously 'ToSymbol' was found by loading the initial value stored at
the fixup location and treating this as an address to search for. This
is incorrect, however: the initial value includes the addend and will
point to the wrong block if the addend is less than zero or greater than
the block size.

rdar://65756694
@lhames
Copy link
Author

lhames commented Jul 20, 2020

@swift-ci please test

@lhames lhames requested a review from lgerbarg July 20, 2020 18:05
Copy link

@lgerbarg lgerbarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

#
# jitlink-check: *{8}anon_minuend_quad1 = section_addr(macho_reloc.o, __data) - anon_minuend_quad1 + 2
# jitlink-check: *{8}anon_minuend_quad1 = section_addr(macho_reloc.o, __data) - anon_minuend_quad1 - 2
# Only the form "B: .quad LA - B + C" is tested. The form "B: .quad B - LA + C" is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment be "B: .quad B - LA - C" (or do you want to keep the addition as the canonical form of the relocation with the understanding C C is negative?"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep -- that expression is referencing the canonical form, though that's less clear now that the example has a negative addend. I'll fix that comment on the mainline to clarify.

@lhames lhames merged commit 801a49e into swiftlang:apple/stable/20200108 Jul 20, 2020
@lhames lhames deleted the rdar65756694-fix-jitlink-macho-subtractors branch July 20, 2020 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants