[PATCH v2] elf: Add DL_ADDRESS_WITHOUT_RELOC [BZ #33088]
H.J. Lu
hjl.tools@gmail.com
Mon Jun 16 08:10:11 GMT 2025
On Mon, Jun 16, 2025 at 3:47 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > diff --git a/elf/dl-before-reloc.h b/elf/dl-before-reloc.h
> > new file mode 100644
> > index 0000000000..4da1bcb776
> > --- /dev/null
> > +++ b/elf/dl-before-reloc.h
> > @@ -0,0 +1,30 @@
>
> > +static __always_inline const void *
> > +_dl_get_var_before_reloc (const void *var)
> > +{
> > + const void *address = var;
> > + /* Force VAR into a general purpose register to prevent loading it
> > + into a vector register directly. */
> > + asm ("" : "+r"(address));
> > + return address;
> > +}
>
> I think this has to be a macro unfortunately (with a statement
> expression), to preserve type safety. And for
> HIDDEN_VAR_NEEDS_DYNAMIC_RELOC architectures, the macro should just
> expand to its argument because for those architectures, we deal with the
> problem by other means.
>
> I would prefer DL_ADDRESS_WITHOUT_RELOC or something like that, to show
> that this is a macro (but maybe that's not important), and to not imply
> that it only works before relocation.
>
Done. Here is the patch:
Add DL_ADDRESS_WITHOUT_RELOC to force an address into a general purpose
register to prevent loading it into a vector register directly before
run-time relocation. Change _end from
extern char _end[] attribute_hidden;
to
extern char _end attribute_hidden;
so that DL_ADDRESS_WITHOUT_RELOC can be used to get its address.
This is an updated fix for BZ #33088.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-elf-Add-DL_ADDRESS_WITHOUT_RELOC-BZ-33088.patch
Type: text/x-patch
Size: 3306 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250616/165d5dcf/attachment.bin>
More information about the Libc-alpha
mailing list