Mark functions/variables directly accessed by assembly as HIDDEN
Assembly code accesses symbols (variables/functions) such as
x264_8_cabac_trnsition_unary
and x264_10_cabac_encode_ue_bypass
PC
relatively, without going through GOT entries. This implies these
symbols must be non-preemptible (cannot be provided by main executable
or another DSO).
Any DSO (including libx264.so
or application DSO linking libx264.a
)
linked from such object files requires -Bsymbolic
to make the symbols
non-preemptible. However, -Bsymbolic
is dangerous as it breaks C++
semantics about address uniqueness of inline functions, type_info (used
by exceptions). This means libx264.a
can not be safely linked into a C++
application DSO.
This patch adds the macro HIDDEN
and marks symbols referenced by
assembly as HIDDEN
. Without -Bsymbolic
, the following command won't fail
with link errors like "relocation R_X86_64_PC32 cannot be used against
symbol ...":
ld --whole-archive libx264.a -shared -o /dev/null
Another advantage is that even in PIC mode, a C compiler will access such symbols directly instead of going through a GOT entry.