[Bug binutils/27484] clang++: objdump: DWARF error: could not find variable specification at offset

2021-07-08 Thread frank.mehnert at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27484

Frank Mehnert  changed:

   What|Removed |Added

 CC||frank.mehnert at gmail dot com

--- Comment #9 from Frank Mehnert  ---
Please consider porting this fix to the binutils 2.36 branch. I have the same
problem there. Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/18028] 32-bit ld runs out of memory when linking 32-bit clang with debug info

2021-07-08 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=18028

--- Comment #3 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a8dde0a2114f87bcdc19946aeab26788f5eae1b7

commit a8dde0a2114f87bcdc19946aeab26788f5eae1b7
Author: H.J. Lu 
Date:   Tue Feb 27 12:22:58 2018 -0800

ld: Limit cache size and add --max-cache-size=SIZE

When link_info.keep_memory is true, linker caches the relocation
information and symbol tables of input files in memory.  When there
are many input files with many relocations, we may run out of memory.
Add --max-cache-size=SIZE to set the maximum cache size.

bfd/

PR ld/18028
* bfd.c (bfd): Add alloc_size.
* elf-bfd.h (_bfd_elf_link_info_read_relocs): New.
* elf32-i386.c (elf_i386_check_relocs): Use _bfd_link_keep_memory.
Update cache_size.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elflink.c (_bfd_elf_link_read_relocs): Renamed to ...
(_bfd_elf_link_info_read_relocs): This.  Update cache_size.
(_bfd_elf_link_read_relocs): New.
(_bfd_elf_link_check_relocs): Call _bfd_elf_link_info_read_relocs
instead of _bfd_elf_link_read_relocs.
(elf_link_add_object_symbols): Likewise.
(elf_link_input_bfd): Likewise.
(init_reloc_cookie_rels): Likewise.
(init_reloc_cookie): Update cache_size.  Call
_bfd_elf_link_info_read_relocs instead of
_bfd_elf_link_read_relocs.
(link_info_ok): New.
(elf_gc_smash_unused_vtentry_relocs): Updated.  Call
_bfd_elf_link_info_read_relocs instead of
_bfd_elf_link_read_relocs.
(bfd_elf_gc_sections): Use link_info_ok.  Pass &link_info_ok
to elf_gc_smash_unused_vtentry_relocs.
* libbfd-in.h (_bfd_link_keep_memory): New.
* linker.c (_bfd_link_keep_memory): New.
* opncls.c (bfd_alloc): Update alloc_size.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

include/

PR ld/18028
* bfdlink.h (bfd_link_info): Add cache_size and max_cache_size.

ld/

PR ld/18028
* NEWS: Mention --max-cache-size=SIZE.
* ld.texi: Document --max-cache-size=SIZE.
* ldlex.h (option_values): Add OPTION_MAX_CACHE_SIZE.
* ldmain.c: (main): Set link_info.max_cache_size to -1.
* lexsup.c (ld_options): Add --max-cache-size=SIZE.
(parse_args): Support OPTION_MAX_CACHE_SIZE.
* testsuite/ld-bootstrap/bootstrap.exp: Add test for
--max-cache-size=-1.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/21782] Fail to create static PIE with undefined weak symbols

2021-07-08 Thread i at maskray dot me
https://sourceware.org/bugzilla/show_bug.cgi?id=21782

Fangrui Song  changed:

   What|Removed |Added

 CC||i at maskray dot me

--- Comment #6 from Fangrui Song  ---
I think suppressing the diagnostic is wrong (QoI issue).

% cat x86.s
.globl _start
.weak foo
_start:
  leaq foo(%rip), %rax
% gcc -fuse-ld=bfd -pie -nostdlib x86.s
# incorrectly passed

The correct behavior should be an error like aarch64 (and many other ports):

% cat a64.s
.globl _start
.weak foo
_start:
  adrpx0, foo
% aarch64-linux-gnu-gcc -pie -nostdlib a64.s
/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/ld:
/tmp/ccdNIlJG.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `foo'
which may bind externally can not be used when making a shared object;
recompile with -fPIC
/tmp/ccdNIlJG.o: in function `_start':
(.text+0x0): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status


The compiler uses GOT indirection for external weak objects, so being rigid for
PC-relative relocation referencing an undefined weak symbol in ld isn't a
compatibility problem.

% cat a.c
__attribute__((weak)) extern int var;
int *f() { return &var; }
% gcc -fpie -O2 -S a.c -o - | grep var
movqvar@GOTPCREL(%rip), %rax
.weak   var

---

The glibc configure-time check should be changed to use GOT:

--- i/sysdeps/x86_64/configure
+++ w/sysdeps/x86_64/configure
@@ -118,7 +118,7 @@ else
.global _start
.weak foo
 _start:
-   leaqfoo(%rip), %rax
+   leaqfoo@gotpcrel(%rip), %rax
 EOF
   libc_cv_pie_option="-Wl,-pie"
   if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib
$no_ssp $libc_cv_pie_option -o conftest conftest.s 1>&5'
diff --git i/sysdeps/x86_64/configure.ac w/sysdeps/x86_64/configure.ac
index ec776274af..e0639bc68e 100644
--- i/sysdeps/x86_64/configure.ac
+++ w/sysdeps/x86_64/configure.ac
@@ -64,7 +64,7 @@ cat > conftest.s <<\EOF
.global _start
.weak foo
 _start:
-   leaqfoo(%rip), %rax
+   leaqfoo@gotpcrel(%rip), %rax
 EOF
   libc_cv_pie_option="-Wl,-pie"
   if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles
-nostdlib $no_ssp $libc_cv_pie_option -o conftest conftest.s
1>&AS_MESSAGE_LOG_FD); then


I tested a trunk ld.lld (will be included in 13.0.0) which reports `error:
relocation R_X86_64_PC32 cannot be used against symbol foo; recompile with
-fPIC`
glibc build with /usr/local/bin/ld pointing to ld.lld works
with
"csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied IRELATIVE
relocations"
and
"configure: Allow LD to be LLD 9.0.0 or above"
i.e. glibc build doesn't need the diagnostic suppression.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/21782] Fail to create static PIE with undefined weak symbols

2021-07-08 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=21782

--- Comment #7 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=661b504df9bfb8d7c5d669091720e1dc0079c05e

commit 661b504df9bfb8d7c5d669091720e1dc0079c05e
Author: H.J. Lu 
Date:   Thu Jul 8 13:49:17 2021 -0700

x86-64: Disallow PC reloc against weak undefined symbols in PIE

Disallow PC relocations against weak undefined symbols in PIE since they
can lead to non-zero address at run-time.

bfd/

PR ld/21782
* elf64-x86-64.c (elf_x86_64_relocate_section): Disallow PC
relocations against weak undefined symbols in PIE.

ld/

PR ld/21782
* testsuite/ld-x86-64/pie3.d: Expect linker error.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/21782] Fail to create static PIE with undefined weak symbols

2021-07-08 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=21782

--- Comment #8 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_37-branch branch has been updated by H.J. Lu
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cce64d8d01ba1558f9fc93775b9d96b40a019199

commit cce64d8d01ba1558f9fc93775b9d96b40a019199
Author: H.J. Lu 
Date:   Thu Jul 8 14:03:53 2021 -0700

x86-64: Disallow PC reloc against weak undefined symbols in PIE

Disallow PC relocations against weak undefined symbols in PIE since they
can lead to non-zero address at run-time.

bfd/

PR ld/21782
* elf64-x86-64.c (elf_x86_64_relocate_section): Disallow PC
relocations against weak undefined symbols in PIE.

ld/

PR ld/21782
* testsuite/ld-x86-64/pie3.d: Expect linker error.

(cherry picked from commit 661b504df9bfb8d7c5d669091720e1dc0079c05e)

-- 
You are receiving this mail because:
You are on the CC list for the bug.