-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: cmd/link: align symbols to an architecture specific minimum value #14604
Comments
I think this is fine.
|
Sounds good. |
Does this affect the alignment for 1-byte values allocated on the stack or in the heap? (It sounds like no, but I want to be clear.) |
No, it won't affect heap/stack data alignment at all.
|
SGTM |
CL https://golang.org/cl/20149 mentions this issue. |
CL https://golang.org/cl/20214 mentions this issue. |
Minalign > 1 implies that relocations inserted by the linker cannot target arbitrary bytes. Related to #14604 Change-Id: Ie68d14887bc4047d9b29b0cb1149a8d14b6c62e2 Reviewed-on: https://go-review.googlesource.com/20214 Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
In the upcoming z (s390x) port all data symbols (i.e. global variables and constants) need to be 2-byte aligned to facilitate relative addressing. To implement this I propose:
Minalign
field to complement theMaxalign
field inld.Arch
Minalign
in thesymalign
function in cmd/link/internal/ld/data.goFor all preexisting architectures the value of
Minalign
would be 1.Other architectures could also use this property to enable some optimizations. For example on platforms where single byte loads are more expensive than n byte loads
Minalign
could be set to n to ensure that all globalbool
variables are aligned to n bytes enabling the use of n byte loads/stores.Note: this would only apply to global variables (or constants), not struct fields or array elements. So in the following example
a
,b
andc
would all consume, and be aligned to, 2 bytes in the data section. Currentlya
would only consume 1 byte and all of them would be aligned to 1 byte:CL to follow shortly. Currently setting Minalign to a value > 8 breaks the code that reads
firstmoduledata
.The text was updated successfully, but these errors were encountered: