[Bug binutils/25870] New: objdump: unable to disassemble a project with large bss section

2020-04-24 Thread zhongyunde at huawei dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25870

Bug ID: 25870
   Summary: objdump: unable to disassemble a project with large
bss section
   Product: binutils
   Version: 2.34
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: zhongyunde at huawei dot com
  Target Milestone: ---

base no the New released binutils 6.34, when you try objdump -SD a.out > a.dump
, you'll get an error similar with follow info, so I think the check in
function bfd_get_full_section_contents need more constraint.


error: a.out(.bss) section size (0x400038 bytes) is larger than file size
(0x184c bytes)
Reading section .bss failed because: memory exhausted

= test case ==
int garray[0x10]; /* define a large bss section */

int main ()
{
 return 0;
}

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


[Bug binutils/25870] objdump: unable to disassemble a project with large bss section

2020-04-24 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25870

Nick Clifton  changed:

   What|Removed |Added

 CC||nickc at redhat dot com

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

  Please could you upload the a.out file that has this problem ?

  The code (in bfd/compress.c:bdf_get_full_section_contents) that is
  producing this error message already has a check for .bss sections:

  /* PR 24753: Sections which have no content should also be
 excluded as they contain no size on disk.  */
  && (bfd_section_flags (sec) & SEC_HAS_CONTENTS) != 0

  So in theory this error should not happen.

Cheers
  Nick

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


[Bug binutils/25870] objdump: unable to disassemble a project with large bss section

2020-04-24 Thread zhongyunde at huawei dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25870

--- Comment #2 from zhongyunde at huawei dot com  
---
Created attachment 12488
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12488&action=edit
./bin/armeb-linux-gnueabi-gcc main.c -o a.out

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


[Bug binutils/25870] objdump: unable to disassemble a project with large bss section

2020-04-24 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25870

Nick Clifton  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #3 from Nick Clifton  ---
Hi zhondyunde,

  Thanks for the upload.  With that I was able to reproduce the problem
  and also find that it has already been fixed.  As a result of PR 24753.
  Which I actually mentioned in my previous post but forgot to check.
  Doh!

Cheers
  Nick

*** This bug has been marked as a duplicate of bug 24753 ***

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


[Bug ld/24753] [2.33 Regression] ld: section size (0x1e50 bytes) is larger than file size (0x5a0 bytes), can not size stub section: memory exhausted

2020-04-24 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24753

Nick Clifton  changed:

   What|Removed |Added

 CC||zhongyunde at huawei dot com

--- Comment #18 from Nick Clifton  ---
*** Bug 25870 has been marked as a duplicate of this bug. ***

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


[Bug gold/25872] New: ifuncmain7.c:47: error: relocation overflow: reference to local symbol 5 in ifuncmain7.o

2020-04-24 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25872

Bug ID: 25872
   Summary: ifuncmain7.c:47: error: relocation overflow: reference
to local symbol 5 in ifuncmain7.o
   Product: binutils
   Version: 2.35 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: gold
  Assignee: ccoutant at gmail dot com
  Reporter: hjl.tools at gmail dot com
CC: ian at airs dot com
  Target Milestone: ---
Target: x86-64

Compile gold with GCC 9 plus -fcf-protection on Linux/x86-64, I got

/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:47:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:55:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:57:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:61:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:63:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:66:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:68:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o
/export/gnu/import/git/gitlab/x86-binutils/gold/testsuite/ifuncmain7.c:70:
error: relocation overflow: reference to local symbol 5 in ifuncmain7.o

ld works on the same inputs.

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


[Bug gold/25872] ifuncmain7.c:47: error: relocation overflow: reference to local symbol 5 in ifuncmain7.o

2020-04-24 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25872

--- Comment #1 from H.J. Lu  ---
template
uint64_t
Output_data_plt_x86_64_ibt::do_address_for_local(const Relobj* object,
 unsigned int r_sym)
{
  // Convert the PLT offset into an APLT offset.
  unsigned int plt_offset = ((object->local_plt_offset(r_sym) - plt_entry_size)
 / (plt_entry_size / aplt_entry_size));
  return (this->address()
  + this->aplt_offset_
  + this->regular_count() * aplt_entry_size
  + plt_offset);
}

(gdb) p r_sym
$27 = 5
(gdb) p object->local_plt_offset(r_sym)
$28 = 0
(gdb) 

((object->local_plt_offset(r_sym) - plt_entry_size) is negative.

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


[Bug binutils/25870] objdump: unable to disassemble a project with large bss section

2020-04-24 Thread zhongyunde at huawei dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25870

--- Comment #4 from zhongyunde at huawei dot com  
---
(In reply to Nick Clifton from comment #3)
> Hi zhondyunde,
> 
>   Thanks for the upload.  With that I was able to reproduce the problem
>   and also find that it has already been fixed.  As a result of PR 24753.
>   Which I actually mentioned in my previous post but forgot to check.
>   Doh!
> 
> Cheers
>   Nick
> 
> *** This bug has been marked as a duplicate of bug 24753 ***

Yeah, I see.
As the issue is fixed at 21 Apr 2020, and binutils 2.34 is released at 1 Feb
2020 before that day, so it is natural that it doesn't fix in such version.

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


[Bug binutils/25870] objdump: unable to disassemble a project with large bss section

2020-04-24 Thread zhongyunde at huawei dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25870

zhongyunde at huawei dot com  changed:

   What|Removed |Added

 CC||zhongyunde at tom dot com

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


[Bug gold/25872] Gold doesn't properly support CET PLT

2020-04-24 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25872

H.J. Lu  changed:

   What|Removed |Added

Summary|ifuncmain7.c:47: error: |Gold doesn't properly
   |relocation overflow:|support CET PLT
   |reference to local symbol 5 |
   |in ifuncmain7.o |

--- Comment #2 from H.J. Lu  ---
template
uint64_t
Output_data_plt_x86_64_ibt::do_address_for_global(const Symbol* gsym)
{
  uint64_t offset = this->aplt_offset_;
  // Convert the PLT offset into an APLT offset.
  unsigned int plt_offset = gsym->plt_offset();
  if (gsym->type() == elfcpp::STT_GNU_IFUNC
  && gsym->can_use_relative_reloc(false))
offset += this->regular_count() * aplt_entry_size;
  else 
plt_offset -= plt_entry_size;
  plt_offset = plt_offset / (plt_entry_size / aplt_entry_size);
  return this->address() + offset + plt_offset;
}

checks STT_GNU_IFUNC.  But do_address_for_local doesn't.  Even with

diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 1442a009d7..284809c719 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -2288,7 +2288,12 @@
Output_data_plt_x86_64_ibt::do_address_for_local(const Relobj* object,
   unsigned int r_sym)
 {
   // Convert the PLT offset into an APLT offset.
-  unsigned int plt_offset = ((object->local_plt_offset(r_sym) -
plt_entry_size)
+  const Sized_relobj_file* sized_relobj =
+static_cast*>(object);
+  const Symbol_value* psymval = sized_relobj->local_symbol(r_sym);
+  unsigned int plt_offset = ((object->local_plt_offset(r_sym)
+  - (psymval->is_ifunc_symbol()
+? 0 : plt_entry_size))
  / (plt_entry_size / aplt_entry_size));
   return (this->address()
 + this->aplt_offset_

I got

/export/gnu/import/git/gitlab/x86-binutils/gold/../test-driver: line 107:
299279 Segmentation fault  (core dumped) "$@" > $log_file 2>&1
FAIL: tls_shared_gnu2_test

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


[Bug gold/25872] Gold doesn't properly support IBT PLT

2020-04-24 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25872

H.J. Lu  changed:

   What|Removed |Added

Summary|Gold doesn't properly   |Gold doesn't properly
   |support CET PLT |support IBT PLT

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


[Bug binutils/25873] New: ar segfaults when liblto_plugin.so.0.0.0 is a symlink in /usr/lib/bfd-plugins

2020-04-24 Thread tstellar at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25873

Bug ID: 25873
   Summary: ar segfaults when liblto_plugin.so.0.0.0 is a symlink
in /usr/lib/bfd-plugins
   Product: binutils
   Version: 2.34
Status: NEW
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: tstellar at redhat dot com
  Target Milestone: ---

ar segfaults when using a plugin from /usr/lib/bfd-plugins that is a symlink. 
Here is how to reproduce:

echo "int foo(){}" | gcc -flto -O2 -c -x c -o foo.o -
echo "int bar(){}" | gcc -flto -O2 -c -x c -o bar.o -
ln -s /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so.0.0.0
/usr/lib/bfd-plugins/
ar crs foo.a foo.o bar.o
Segmentation fault (core dumped)


If the plugin is copied directly and not a symlink, then there is no segfault:


rm /usr/lib/bfd-plugins/liblto_plugin.so.0.0.0 
cp /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so.0.0.0
/usr/lib/bfd-plugins/
ar crs foo.a foo.o bar.o

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


[Bug binutils/25873] ar segfaults when liblto_plugin.so.0.0.0 is a symlink in /usr/lib/bfd-plugins

2020-04-24 Thread tstellar at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=25873

--- Comment #1 from Tom Stellard  ---
It also seems like the LLVMgold.so plugin does not have the same problem.  This
similar sequence works with this plugin:

echo "int foo(){}" | clang -flto -O2 -c -x c -o foo.o -
echo "int bar(){}" | clang -flto -O2 -c -x c -o bar.o -
ln -s /usr/lib64/LLVMgold.so /usr/lib/bfd-plugins/
ar crs foo.a foo.o bar.o

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