Skip to content

Use GOT to access data within LEA macro

Pranav Kant requested to merge pranavk/dav1d:mcmodel into master

This is to support building all data under medium code model, eg: using -mcmodel=medium -mlarge-data-threshold=0. Code built with these options is organized in final binary such that all data >= 0 bytes is considered large and any reference to this data from .text section is accessed via GOT. Hardcoded assembly without any wrt (WithReferenceTo) annotation accesses the variable directly assuming small code model. This commit changes LEA macro so that such accesses go via GOT.

Performance-wise, modern linkers are smart enough to remove that additional GOT access, if the final binary size ends up being smaller.

Some general information about code models: https://eli.thegreenplace.net/2012/01/03/understanding-the-x64-code-models

Edited by Pranav Kant

Merge request reports

Loading