[PATCH v2] x86: Properly handle relocation against local ABS symbol

Maciej W. Rozycki macro@orcam.me.uk
Sat May 17 03:18:02 GMT 2025
On Fri, 16 May 2025, H.J. Lu wrote:

> /* Return TRUE if the symbol described by a linker hash entry H is a
>    local symbol which is going to be absolute.  */
> #define LOCAL_ABS_SYMBOL_P(INFO, H) \
>   (bfd_is_abs_symbol (&(H)->root) \
>    && (bfd_link_executable (INFO) \
>        || ELF_ST_VISIBILITY ((H)->other) == STV_HIDDEN \
>        || ELF_ST_VISIBILITY ((H)->other) == STV_PROTECTED))

 Without diving into the rest of discussion why not:

   && (bfd_link_executable (INFO) \
       || ELF_ST_VISIBILITY ((H)->other) == STV_INTERNAL \
       || ELF_ST_VISIBILITY ((H)->other) == STV_HIDDEN \
       || ELF_ST_VISIBILITY ((H)->other) == STV_PROTECTED))

or simply:

   && (bfd_link_executable (INFO) \
       || ELF_ST_VISIBILITY ((H)->other) != STV_DEFAULT))

? -- as all !STV_DEFAULT export class symbols bind locally.

 NB the check for `bfd_link_executable' isn't clear to me in the context 
of the explanatory comment and the macro name as in executables actually 
all symbols bind locally.

  Maciej


More information about the Binutils mailing list