Skip to content

aarch64: Split the jump tables to a separate const section

Martin Storsjö requested to merge mstorsjo/dav1d:xonly into master

This should allow executing in environments where the executable memory isn't readable.

Use 4 byte entries instead of 2; most object file formats support relocations for a 4 byte symbol difference across sections, which allows keeping the rest of the table lookup code similar to what it was before.

Referencing a symbol in an arbitrary location in the executable requires a two instruction sequence (adrp+add, via the movrel macro).

Thus, the cost of this rewrite is doubling the size of the jump tables (which were quite small so far), and adding one instruction in each jump table setup prologue. On an ELF build, the .text section shrinks by 1176 bytes, and the .rodata section grows by 3136 bytes, i.e. a 1960 byte increase.

MS armasm64 doesn't seem to support calculating symbol differences across sections (see [1]), so keep the jump tables in the text section there, to let the assembler calculate it at assembly time instead. (Keeping the condition as _WIN32 for simplicity, as we don't interact directly with armasm64, but it is wrapped in gas-preprocessor.)

[1] https://developercommunity.visualstudio.com/t/armasm64-unable-to-create-cross-section/10722340

Merge request reports

Loading