public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] aarch64: define PI_STATIC_AND_HIDDEN
Date: Mon, 11 Jan 2021 10:45:36 +0000	[thread overview]
Message-ID: <20210111104536.GW2379@arm.com> (raw)
In-Reply-To: <20210106133121.19286-1-szabolcs.nagy@arm.com>

The 01/06/2021 13:31, Szabolcs Nagy via Libc-alpha wrote:
> AArch64 always uses pc relative access to static and hidden object
> symbols, but the config setting was previously missing.
> 
> This affects ld.so start up code.
> ---
> it seems to me that this was missing because of an oversight.
> i plan to commit this tomorrow unless there are comments.


since this commit the aarch64 build is failing with
gcc-8 or older.

gcc   -nostdlib -nostartfiles -shared -o /work/glibc-aarch64-linux/build/build/elf/ld.so.new            \
          -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs       \
          /work/glibc-aarch64-linux/build/build/elf/librtld.os -Wl,--version-script=/work/glibc-aarch64-linux/build/build/ld.map                \
          -Wl,-soname=ld-linux-aarch64.so.1                     \
          -Wl,-defsym=_begin=0
/usr/bin/ld: /work/glibc-aarch64-linux/build/build/elf/librtld.os: in function `elf_get_dynamic_info':
/work/glibc-aarch64-linux/build/glibc/elf/get-dynamic-info.h:70:(.text+0xad8): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `_rtld_local' defined in .data section in /work/glibc-aarch64-linux/build/build/elf/librtld.os
/usr/bin/ld: /work/glibc-aarch64-linux/build/glibc/elf/get-dynamic-info.h:73:(.text+0xae8): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `_rtld_local' defined in .data section in /work/glibc-aarch64-linux/build/build/elf/librtld.os
/usr/bin/ld: /work/glibc-aarch64-linux/build/glibc/elf/get-dynamic-info.h:60:(.text+0xaf0): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `_rtld_local' defined in .data section in /work/glibc-aarch64-linux/build/build/elf/librtld.os
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:580: /work/glibc-aarch64-linux/build/build/elf/ld.so] Error 1

this explains why PI_STATIC_AND_HIDDEN was not defined
for aarch64 earlier, however i think this is a gcc bug,
i opened

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98618

i'm trying to do a workaround in glibc now.

> 
> my current plan for bug 27072 is to mark things hidden in
> static pie libc and then if this macro is defined then
> reorder the self reloc code after auxv, tunables etc are
> set up (this requires that nothing depends on ifuncs and
> global pointers up to that point).
> 
>  sysdeps/aarch64/configure    | 5 +++++
>  sysdeps/aarch64/configure.ac | 4 ++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/sysdeps/aarch64/configure b/sysdeps/aarch64/configure
> index 1f8223725f..5f5f3cc44c 100644
> --- a/sysdeps/aarch64/configure
> +++ b/sysdeps/aarch64/configure
> @@ -1,6 +1,11 @@
>  # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
>   # Local configure fragment for sysdeps/aarch64.
>  
> +# Static and hidden objects are accessed without dynamic relocations.
> +# The exception is -mcmodel=large which is unsupported with PIC/PIE.
> +$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
> +
> +
>  # We check to see if the compiler and flags are
>  # selecting the big endian ABI and if they are then
>  # we set libc_cv_aarch64_be to yes which causes
> diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac
> index da2a8d81d0..180a16a29f 100644
> --- a/sysdeps/aarch64/configure.ac
> +++ b/sysdeps/aarch64/configure.ac
> @@ -1,6 +1,10 @@
>  GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
>  # Local configure fragment for sysdeps/aarch64.
>  
> +# Static and hidden objects are accessed without dynamic relocations.
> +# The exception is -mcmodel=large which is unsupported with PIC/PIE.
> +AC_DEFINE(PI_STATIC_AND_HIDDEN)
> +
>  # We check to see if the compiler and flags are
>  # selecting the big endian ABI and if they are then
>  # we set libc_cv_aarch64_be to yes which causes
> -- 
> 2.17.1
> 

-- 

      parent reply	other threads:[~2021-01-11 10:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-06 13:31 Szabolcs Nagy
2021-01-06 18:15 ` Szabolcs Nagy
2021-01-06 20:20   ` Adhemerval Zanella
2021-01-11 10:45 ` Szabolcs Nagy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111104536.GW2379@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).