unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: fix elf_machine_dynamic compile error [BZ #29835]
@ 2022-12-02  3:53 linzhuorong via Libc-alpha
  0 siblings, 0 replies; 4+ messages in thread
From: linzhuorong via Libc-alpha @ 2022-12-02  3:53 UTC (permalink / raw)
  To: libc-alpha; +Cc: nixiaoming, linzhuorong

elf_machine_dynamic compile error when compiling glibc with --enable-static-pie option turned on, static executables do not have symbol _DYNAMIC

Fixes: bca0f5cbc9257c13322b99e55235c4f21ba0bd82("aarch64: Make elf_machine_{load_address,dynamic} robust [BZ #28203]")

Signed-off-by linzhuorong <linzhuorong@huawei.com>
---
 sysdeps/aarch64/dl-machine.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index ae8b14425a..49b1d1ea0e 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -53,8 +53,9 @@ elf_machine_load_address (void)
 static inline ElfW(Addr) __attribute__ ((unused))
 elf_machine_dynamic (void)
 {
-  extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
-  return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
+  /* Declaring this hidden ensures that a PC-relative reference is uesed.  */
+  extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
+  return _GLOBAL_OFFSET_TABLE_[0];
 }
 
 /* Set up the loaded object described by L so its unrelocated PLT
-- 
2.12.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] aarch64: fix elf_machine_dynamic compile error [BZ #29835]
@ 2022-12-02  3:54 linzhuorong via Libc-alpha
  0 siblings, 0 replies; 4+ messages in thread
From: linzhuorong via Libc-alpha @ 2022-12-02  3:54 UTC (permalink / raw)
  To: libc-alpha; +Cc: nixiaoming, xiaojiangfeng, linzhuorong

elf_machine_dynamic compile error when compiling glibc with --enable-static-pie option turned on, static executables do not have symbol _DYNAMIC

Fixes: bca0f5cbc9257c13322b99e55235c4f21ba0bd82("aarch64: Make elf_machine_{load_address,dynamic} robust [BZ #28203]")

Signed-off-by linzhuorong <linzhuorong@huawei.com>
---
 sysdeps/aarch64/dl-machine.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index ae8b14425a..49b1d1ea0e 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -53,8 +53,9 @@ elf_machine_load_address (void)
 static inline ElfW(Addr) __attribute__ ((unused))
 elf_machine_dynamic (void)
 {
-  extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
-  return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
+  /* Declaring this hidden ensures that a PC-relative reference is uesed.  */
+  extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
+  return _GLOBAL_OFFSET_TABLE_[0];
 }
 
 /* Set up the loaded object described by L so its unrelocated PLT
-- 
2.12.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] aarch64: fix elf_machine_dynamic compile error [BZ #29835]
@ 2022-12-02  3:59 linzhuorong via Libc-alpha
  2022-12-05 14:54 ` Szabolcs Nagy via Libc-alpha
  0 siblings, 1 reply; 4+ messages in thread
From: linzhuorong via Libc-alpha @ 2022-12-02  3:59 UTC (permalink / raw)
  To: libc-alpha
  Cc: nixiaoming, xiaojiangfeng, douzhaolei, wangbing6, wangfangpeng1,
	young.liuyang, linzhuorong

elf_machine_dynamic compile error when compiling glibc with --enable-static-pie option turned on, static executables do not have symbol _DYNAMIC

Fixes: bca0f5cbc9257c13322b99e55235c4f21ba0bd82("aarch64: Make elf_machine_{load_address,dynamic} robust [BZ #28203]")

Signed-off-by linzhuorong <linzhuorong@huawei.com>
---
 sysdeps/aarch64/dl-machine.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index ae8b14425a..49b1d1ea0e 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -53,8 +53,9 @@ elf_machine_load_address (void)
 static inline ElfW(Addr) __attribute__ ((unused))
 elf_machine_dynamic (void)
 {
-  extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
-  return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
+  /* Declaring this hidden ensures that a PC-relative reference is uesed.  */
+  extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
+  return _GLOBAL_OFFSET_TABLE_[0];
 }
 
 /* Set up the loaded object described by L so its unrelocated PLT
-- 
2.12.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] aarch64: fix elf_machine_dynamic compile error [BZ #29835]
  2022-12-02  3:59 linzhuorong via Libc-alpha
@ 2022-12-05 14:54 ` Szabolcs Nagy via Libc-alpha
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy via Libc-alpha @ 2022-12-05 14:54 UTC (permalink / raw)
  To: linzhuorong
  Cc: libc-alpha, nixiaoming, xiaojiangfeng, douzhaolei, wangbing6,
	wangfangpeng1, young.liuyang

The 12/02/2022 11:59, linzhuorong via Libc-alpha wrote:
> elf_machine_dynamic compile error when compiling glibc with --enable-static-pie option turned on, static executables do not have symbol _DYNAMIC

glibc no longer has --enable-static-pie, instead it has
--disable-default-pie .

static pie should have _DYNAMIC symbol since it has dynamic
relocations (relative relocs), what is the binutils version?

maybe glibc should disable default pie if old binutils is
detected.

> 
> Fixes: bca0f5cbc9257c13322b99e55235c4f21ba0bd82("aarch64: Make elf_machine_{load_address,dynamic} robust [BZ #28203]")
> 
> Signed-off-by linzhuorong <linzhuorong@huawei.com>
> ---
>  sysdeps/aarch64/dl-machine.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
> index ae8b14425a..49b1d1ea0e 100644
> --- a/sysdeps/aarch64/dl-machine.h
> +++ b/sysdeps/aarch64/dl-machine.h
> @@ -53,8 +53,9 @@ elf_machine_load_address (void)
>  static inline ElfW(Addr) __attribute__ ((unused))
>  elf_machine_dynamic (void)
>  {
> -  extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
> -  return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
> +  /* Declaring this hidden ensures that a PC-relative reference is uesed.  */
> +  extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
> +  return _GLOBAL_OFFSET_TABLE_[0];
>  }
>  
>  /* Set up the loaded object described by L so its unrelocated PLT
> -- 
> 2.12.3
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-05 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02  3:54 [PATCH] aarch64: fix elf_machine_dynamic compile error [BZ #29835] linzhuorong via Libc-alpha
  -- strict thread matches above, loose matches on Subject: below --
2022-12-02  3:59 linzhuorong via Libc-alpha
2022-12-05 14:54 ` Szabolcs Nagy via Libc-alpha
2022-12-02  3:53 linzhuorong via Libc-alpha

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).