[Bug ld/20402] New: ld.bfd for AArch64 emits R_AARCH64_RELATIVE relocations against SHN_ABS symbols

2016-07-24 Thread ard.biesheuvel at linaro dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=20402

Bug ID: 20402
   Summary: ld.bfd for AArch64 emits R_AARCH64_RELATIVE
relocations against SHN_ABS symbols
   Product: binutils
   Version: 2.28 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: ard.biesheuvel at linaro dot org
  Target Milestone: ---

ld.bfd in -pie mode will 'optimize' away a R_AARCH64_ABS64 relocation against a
hidden SHN_ABS symbol by replacing it with a R_AARCH64_RELATIVE relocation,
which obviously makes the resulting value in the place dependent on the load
offset rather than fixed.

Instead, I would expect either the relocation to be preserved as a
R_AARCH64_ABS64 relocation to be resolved at load time, or be optimized away
completely, since the symbol is hidden and therefore not preemptible and could
thus be fully resolved at link time.

I don't have a small test case handy (I found this while working on KASLR for
arm64 Linux), but the following hunk fixes the problem completely for me: it
not only prevents the R_AARCH64_RELATIVE relocation from being emitted, but it
fully resolves the relocation and puts the correct 64-bit absolute value in the
place in the ELF binary.

diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 3435a3d67339..d1068f56c4ee 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -5191,7 +5191,8 @@
   && h->dynindx != -1
   && (!bfd_link_pic (info)
   || !SYMBOLIC_BIND (info, h)
-  || !h->def_regular))
+  || !h->def_regular
+  || sym->st_shndx == SHN_ABS))
outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type);
  else
{
(

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20402] ld.bfd for AArch64 emits R_AARCH64_RELATIVE relocations against SHN_ABS symbols

2016-07-24 Thread ard.biesheuvel at linaro dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=20402

--- Comment #1 from Ard Biesheuvel  ---
Uhm, actually it does not fix it. I will try to come up with a small
reproducing test case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20402] ld.bfd for AArch64 emits R_AARCH64_RELATIVE relocations against SHN_ABS symbols

2016-07-24 Thread ard.biesheuvel at linaro dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=20402

--- Comment #2 from Ard Biesheuvel  ---
The issue can be reproduced by:

abs.s
-
.quad   foo, bar

abs.lds
---
HIDDEN(foo = ABSOLUTE(0xff00ff11ff22ff33));
bar = ABSOLUTE(0xff44ff55ff66ff77);

Build using

aarch64-linux-gnu-gcc -pie -nostdlib -o abs -T abs.lds abs.s

which produces a binary containing the following relocations

Relocation section '.rela.dyn' at offset 0x100c8 contains 2 entries:
  Offset  Info   Type   Sym. ValueSym. Name +
Addend
  0403 R_AARCH64_RELATIV-ff00ee00dd00cd
0008  00020101 R_AARCH64_ABS64   ff44ff55ff66ff77 bar + 0

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/20404] New: gold/configure --help shall print "

2016-07-24 Thread dilyan.palauzov at aegee dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=20404

Bug ID: 20404
   Summary: gold/configure --help shall print "
   Product: binutils
   Version: 2.28 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: gold
  Assignee: ccoutant at gmail dot com
  Reporter: dilyan.palauzov at aegee dot org
CC: ian at airs dot com
  Target Milestone: ---

Provided that gold/configure always turns on "--enable-relro", contrary to
ld/configure, as gold/configure.tgt and ld/configure.tgt differ, gold/configure
--help shall print

--disable-relrodisable -z relro in ELF linker by default

to indicate, that by not specifying anything, relro will be enabled implicitly
in the compiled gold.  Currently gold/configure --help prints "--enable-relro  
 enable -z relro in ELF linker by default" which indicates the opposite.

Please consider adjusting the output of ld.gold --help as follows.

diff --git a/gold/configure.ac b/gold/configure.ac

index de3b630..742af37 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -118,8 +118,8 @@ AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
 ac_default_ld_z_relro=unset
 # Provide a configure time option to override our default.
 AC_ARG_ENABLE(relro,
- AS_HELP_STRING([--enable-relro],
- [enable -z relro in ELF linker by default]),
+ AS_HELP_STRING([--disable-relro],
+ [disable -z relro in ELF linker by default]),
 [case "${enableval}" in
   yes)  ac_default_ld_z_relro=1 ;;
   no)  ac_default_ld_z_relro=0 ;;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils