[Bug binutils/28697] objdump often doesn't look for separate debug files when using "build-id" style

2021-12-16 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28697

--- Comment #1 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Nick Clifton :

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

commit 61ab1364c7efa3934e0ca62af444e6e6e34f219e
Author: Nick Clifton 
Date:   Thu Dec 16 14:05:40 2021 +

When loading separate debug info files, also attempt to locate a file based
upon the build-id.

PR 28697
* dwarf.c (load_build_id_debug_file): New function.
(try_build_id_prefix): New function.
(check_for_and_load_links): Call load_build_id_debug_file.
(debug_displays): Add entry for .note.gnu.build-id.
* dwarf.h (enum dwarf_section_display_enum): Add
note_gnu_build_id.
* testsuite/binutils-all/debuginfod.exp (test_fetch_debuglink):
Fix regexp for loads via debuglink section.

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


[Bug binutils/28697] objdump often doesn't look for separate debug files when using "build-id" style

2021-12-16 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28697

Nick Clifton  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 CC||nickc at redhat dot com
 Status|UNCONFIRMED |RESOLVED

--- Comment #2 from Nick Clifton  ---
Hi Travis,

  The reason for the discrepancy is that objdump's -S option uses the BFD
library to load DWARF debug information, and this library does include to look
for debuginfo files based upon the build-id.  Objdump's other options all use
the DWARF parsing code shared by programs in the binutils/ directory, and this
code does not/did not look for build-id based debuginfo files.

  I have now checked in a patch to fix this disrepancy, so that the DWARF
parsing code in the binutils/ directory now also looks for build-id based
files.

Cheers
  Nick

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


[Bug ld/28686] [avr] linker relaxations generate incorrect value

2021-12-16 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28686

Nick Clifton  changed:

   What|Removed |Added

   Last reconfirmed||2021-12-16
   Assignee|unassigned at sourceware dot org   |nickc at redhat dot com
 CC||nickc at redhat dot com
 Status|UNCONFIRMED |ASSIGNED
 Ever confirmed|0   |1

--- Comment #1 from Nick Clifton  ---
Hi Joerg,

  The root cause for this problem is the assembler.  When it assembles
  the test file it created a relocation for the LDI instruction which 
  references the .text section:

% objdump -dr main.o
[...]
 4b2:   f0 e0   ldi r31, 0x00   ; 0
4b2: R_AVR_HI8_LDI  .text+0x500

  So when the relaxation happens the code adjusts the relocation
  eventually ending up with .text+0x2ab which then translates into
  a value of 2 (the top 8 bits of the addition) for LDI instruction.

  This error of course is that the relocation should not be against
  an offset from the .text section, but rather against the matrix
  symbol itself.  Since this symbol stays aligned, it does not move
  as far back as the .text+offset value.

  I am currently testing a local patch which stops the assembler
  from trying to optimize away symbol names in relocations if it
  knows that linker relaxation is going to occur.  With this patch
  applied the object file looks like:

   % objdump -dr main.o
   [...]
4b2:f0 e0   ldi r31, 0x00   ; 0
4b2: R_AVR_HI8_LDI  matrix

  And when finally linked the correct value - 3 - is used by the 
  LDI instruction.

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


[Bug ld/28686] [avr] linker relaxations generate incorrect value

2021-12-16 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28686

--- Comment #2 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Nick Clifton :

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

commit f3be70df1b1681ad1b9b0490587011bde433d220
Author: Nick Clifton 
Date:   Thu Dec 16 16:40:57 2021 +

Fix AVR assembler so that it creates relocs that will work with linker
relaxation.

PR 28686
gas * config/tc-avr.h (tc_fix_adjustable): Define.
* config/tc-avr.c (avr_fix_adjustable): New function.
* testsuite/gas/all/gas.exp: Skip tests that need adjustable
fixups.
* testsuite/gas/elf/elf.exp: Likewise.
* testsuite/gas/avr/diffreloc_withrelax.d: Adjust expected output.
* testsuite/gas/avr/pc-relative-reloc.d: Adjust expected output.

ld  * testsuite/ld-avr/avr-prop-7.d: Adjust expected output.
* testsuite/ld-avr/avr-prop-8.d: Likewise.
* testsuite/ld-avr/pr13402.d: Likewise.

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


[Bug ld/28686] [avr] linker relaxations generate incorrect value

2021-12-16 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28686

Nick Clifton  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #3 from Nick Clifton  ---
Patch applied.

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


Issue 40953 in oss-fuzz: binutils:fuzz_objcopy: Integer-overflow in _bfd_elf_compute_section_file_positions

2021-12-16 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #5 on issue 40953 by sheriffbot: binutils:fuzz_objcopy: 
Integer-overflow in _bfd_elf_compute_section_file_positions
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40953#c5

This bug has been fixed. It has been opened to the public.

- Your friendly Sheriffbot

-- 
You received this message because:
  1. You were specifically CC'd on the issue

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Reply to this email to add a comment.

Issue 41352 in oss-fuzz: binutils:fuzz_dwarf: Null-dereference READ in load_separate_debug_files

2021-12-16 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #5 on issue 41352 by sheriffbot: binutils:fuzz_dwarf: Null-dereference 
READ in load_separate_debug_files
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41352#c5

This bug has been fixed. It has been opened to the public.

- Your friendly Sheriffbot

-- 
You received this message because:
  1. You were specifically CC'd on the issue

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Reply to this email to add a comment.

[Bug binutils/28697] objdump often doesn't look for separate debug files when using "build-id" style

2021-12-16 Thread travis.downs at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28697

--- Comment #3 from Travis Downs  ---
Thanks Nick, that's quite the fast turnaround on this one, thanks very much!

Do I understand correctly that things checked into master now will be released
in binutils 2.38?

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


[Bug binutils/28697] objdump often doesn't look for separate debug files when using "build-id" style

2021-12-16 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28697

--- Comment #4 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Alan Modra :

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

commit dbc6a0e2e4bdc70133d9165fb2e15b592bc27c53
Author: Alan Modra 
Date:   Fri Dec 17 08:07:30 2021 +1030

try_build_id_prefix gcc-10 -Wformat-security errors

dwarf.c:11300:3: error: format not a string literal and no format arguments
[-Werror=format-security]
11300 |   f += sprintf (f, prefix);

PR 28697
* dwarf.c (try_build_id_prefix): Avoid -Wformat-security error.

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


[Bug ld/28709] New: [RISC-V] a unused section can't be removed with -gc-sections

2021-12-16 Thread lifang_...@c-sky.com
https://sourceware.org/bugzilla/show_bug.cgi?id=28709

Bug ID: 28709
   Summary: [RISC-V] a unused section can't be removed with
-gc-sections
   Product: binutils
   Version: 2.38 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: lifang_...@c-sky.com
  Target Milestone: ---

Created attachment 13860
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13860&action=edit
source code and command

I have met a situation, but I think it should be bug for ld in RISC-V.
A unused section can't be removed with gc-section.

The attachment contains the sources and command to run:
a.c: a main entry, which only prints "HelloWorld", it does not depend on b.cpp.
a.s: a asm file created by compiling a.c
b.cpp: a cpp with a class, and a function
b.s: a asm file created by compiling b.cpp
b.simple.s: delete some sections from b.s
===
BUILD
riscv64-unknown-elf-gcc -ffunction-sections -fdata-sections -o a.o a.c -c
riscv64-unknown-elf-g++ -ffunction-sections -fdata-sections -o b.o b.cpp -c
riscv64-unknown-elf-g++ -Wl,-gc-sections -o a a.o b.o

I can find the test11 in the output with "readelf -sW a".
Obviously, test11 should be removed. I have tested on ARM and x86, both of
them can remove test11.

b.simple.s is simpler than b.s, I use the gas and ld to do test:
./gas/as-new -o a.o a.s
./gas/as-new -o b.o b.simple.s
./ld/ld-new  -o a a.o b.o -e main --defsym=puts=0 -gc-section
--print-gc-sections

==
the reason why test11 can't be removed is that there is a init_array in
b.simple.s which holds a entry _GLOBAL__sub_I__ZN3Box3getEv,
and _GLOBAL__sub_I__ZN3Box3getEv have a eh_frame. there are only one eh_frame
in b.o, so eh_frame also contains the dwarf about test11.

The gas create some relocs for DW_CFA_advance_loc* which used in linker relax.
The dest symbol of relocs belongs to .text.test11.

So ld can't remove the .text.test11.

=
How to solve

1. Skip gc_mark in riscv_elf_gc_mark_hook
+  /* Ignore the reloc which are used for eh_frame. */
+  if (strcmp(sec->name, ".eh_frame") == 0)
+{
+  switch (ELFNN_R_TYPE (rel->r_info))
+  {
+  case R_RISCV_SET6:
+  case R_RISCV_SUB6:
+  case R_RISCV_SET8:
+  case R_RISCV_SUB8:
+  case R_RISCV_SET16:
+  case R_RISCV_SUB16:
+  case R_RISCV_SET32:
+  case R_RISCV_SUB32:
+return NULL;
+  }
+}

2, Split .eh_frame to .eh_frame.function. It is a good choice, but the dwarf
may not be suitable for that.

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