Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: R_AARCH64_RELATIVE relocations are not right for gcprog for bss/data #11494

Closed
mwhudson opened this issue Jul 1, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@mwhudson
Copy link
Contributor

commented Jul 1, 2015

(this is mostly a note to myself)

To construct the gcprog for the data or bss segment of a dynamically linked module, when confronted with a type defined in a separate module, cmd/link reads the type date out of the module, finds the address of the prog/mask and uses that to then read the mask or prog itself. This works on intel because even though there is a relocation against the address of the mask/prog, the mask/prog is defined as a local symbol and so the relocation is R_X86_64_RELATIVE, which works by adjusting the address that's already in the relocated place by the difference between where the shared library expected to end up in memory and where it did.

However, on arm64, the R_AARCH64_RELATIVE relocation doesn't work like this: it stores the address to be adjusted in the addend of the relocation, and the relocated place contains 0. So the gcprog for the dynamically linked module's bss and data end up being completely wrong and things that should be kept alive by pointers in there are not and the world falls in on itself.

I guess to solve this I need to process the relocations from the shared library to look for the relocations that touch the part of the type data that defines the gcdata. I was trying really hard to avoid doing this because I assumed it would be really slow, I guess now I get to find out if that's right.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jul 11, 2015

@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Jul 11, 2015

FWIW, this was easy to implement and doesn't seem to be impossibly slow (I haven't measured it though).

@rsc rsc changed the title cmd/link: cannot assume that relative relocations get address from place being relocated cmd/link: R_AARCH64_RELATIVE relocations are not right for gcprog for bss/data Nov 5, 2015

@mwhudson

This comment has been minimized.

Copy link
Contributor Author

commented Nov 20, 2015

Fixed in 712ffc0

@mwhudson mwhudson closed this Nov 20, 2015

@golang golang locked and limited conversation to collaborators Nov 27, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.