Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-04 Thread Martin Storsjö
On Wed, 4 Sep 2024, Evgeny Karpov wrote: Monday, September 4, 2024 Martin Storsjö wrote: compilation time adrp x0, symbol + 256 9000 adrp x0, 0 As the symbol offset is 256, you will need to encode the offset "256" in the instruction immediate field. Not "256 >> 12". This is the somewhat

Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-04 Thread Martin Storsjö
On Wed, 4 Sep 2024, Martin Storsjö wrote: On Wed, 4 Sep 2024, Evgeny Karpov wrote: Monday, September 4, 2024 Martin Storsjö wrote: Let's consider the following example, when symbol is located at 3072. 1. Example without the fix compilation time adrp        x0, (3072 + 256) & ~0xFFF // x0 =

Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-04 Thread Martin Storsjö
On Wed, 4 Sep 2024, Evgeny Karpov wrote: Monday, September 4, 2024 Martin Storsjö wrote: Let's consider the following example, when symbol is located at 3072. 1. Example without the fix compilation time adrp        x0, (3072 + 256) & ~0xFFF // x0 = 0 add         x0, x0, (3072 + 256) & 0xFFF

[PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-04 Thread Evgeny Karpov
Monday, September 4, 2024 Martin Storsjö wrote: >> Let's consider the following example, when symbol is located at 3072. >> >> 1. Example without the fix >> compilation time >> adrp        x0, (3072 + 256) & ~0xFFF // x0 = 0 >> add         x0, x0, (3072 + 256) & 0xFFF // x0 = 3328 >> >> linking t

Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-04 Thread Martin Storsjö
On Wed, 4 Sep 2024, Evgeny Karpov wrote: Monday, September 2, 2024 Martin Storsjö wrote: The only non-obvious thing, is that for IMAGE_REL_ARM64_PAGEBASE_REL21, i.e. "adrp" instructions, the immediate that gets stored in the instruction, is the byte offset to the symbol. After linking, when

Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-04 Thread Evgeny Karpov
Monday, September 2, 2024 Martin Storsjö wrote: > The only non-obvious thing, is that for IMAGE_REL_ARM64_PAGEBASE_REL21, > i.e. "adrp" instructions, the immediate that gets stored in the > instruction, is the byte offset to the symbol. > > After linking, when the instruction is interpreted at ex

Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-02 Thread Martin Storsjö
On Mon, 2 Sep 2024, Evgeny Karpov wrote: aarch64.cc has been updated to prevent emitting "symbol + offset" for SYMBOL_SMALL_ABSOLUTE for the PECOFF target. "symbol + offset" cannot be used in relocations for aarch64-w64-mingw32 due to relocation requirements. What relocation requirements are t

Re: [PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-02 Thread Richard Sandiford
Evgeny Karpov writes: > aarch64.cc has been updated to prevent emitting "symbol + offset" > for SYMBOL_SMALL_ABSOLUTE for the PECOFF target. "symbol + offset" > cannot be used in relocations for aarch64-w64-mingw32 due to > relocation requirements. > Instead, it will adjust the address by an offse

[PATCH v1 6/9] aarch64: Use symbols without offset to prevent relocation issues

2024-09-02 Thread Evgeny Karpov
aarch64.cc has been updated to prevent emitting "symbol + offset" for SYMBOL_SMALL_ABSOLUTE for the PECOFF target. "symbol + offset" cannot be used in relocations for aarch64-w64-mingw32 due to relocation requirements. Instead, it will adjust the address by an offset with the "add" instruction. gc