[Bug ld/13616] linker should pad executable sections with nops, not zeros

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

Fangrui Song  changed:

   What|Removed |Added

 CC||i at maskray dot me

--- Comment #10 from Fangrui Song  ---
I know that some x86-32 systems appear to underalign .init and expect ld to pad
with NOPs: https://bugs.llvm.org/show_bug.cgi?id=46364

If we show less mercy to such broken settings, traps are probably better than
nops.

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


[Bug ld/21351] documentation for --relax

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

Fangrui Song  changed:

   What|Removed |Added

 CC||i at maskray dot me

--- Comment #2 from Fangrui Song  ---
The patch looks good:)

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


[Bug ld/26358] --wrap: the special rule for "undefined symbol" is incompatible with -flto or relocatable links

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

Fangrui Song  changed:

   What|Removed |Added

 CC||dilyan.palauzov at aegee dot 
org

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


[Bug ld/26358] New: --wrap: the special rule for "undefined symbol" is incompatible with -flto or relocatable links

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

Bug ID: 26358
   Summary: --wrap: the special rule for "undefined symbol" is
incompatible with -flto or relocatable links
   Product: binutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: i at maskray dot me
  Target Milestone: ---

The manpage says

> Only undefined references are replaced by the linker.  So, translation unit 
> internal references to symbol are not resolved to "__wrap_symbol". In the 
> next example, the call to "f" in "g" is not resolved to "__wrap_f".

The "undefined reference" rule can cause different views in non-LTO and LTO (or
-r).

>a.c foo) so that all relocations to foo or __real_foo will be redirected.

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


[Bug binutils/26357] New: Building binutils with plugins enabled breaks ar/ranlib symbol table on 32-bit HP-UX

2020-08-08 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=26357

Bug ID: 26357
   Summary: Building binutils with plugins enabled breaks
ar/ranlib symbol table on 32-bit HP-UX
   Product: binutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: danglin at gcc dot gnu.org
  Target Milestone: ---
  Host: hppa2.0w-hp-hpux11.11
Target: hppa2.0w-hp-hpux11.11
 Build: hppa2.0w-hp-hpux11.11

../src/configure --prefix=/opt/gnu --disable-nls --disable-gdb

-bash-4.4$ cd binutils
-bash-4.4$ ./ar r libx.a *.o
./ar: creating libx.a
-bash-4.4$ /usr/ccs/bin/nm libx.a

nm:  addr2line.o:  bad magic

nm:  ar.o:  bad magic

nm:  arlex.o:  bad magic

nm:  arparse.o:  bad magic

nm:  arsup.o:  bad magic

nm:  bfdtest1.o:  bad magic

nm:  bfdtest2.o:  bad magic

nm:  binemul.o:  bad magic

nm:  binutils_tg.o:  bad magic

nm:  bucomm.o:  bad magic

nm:  cxxfilt.o:  bad magic

nm:  debug.o:  bad magic

nm:  dwarf.o:  bad magic

nm:  elfcomm.o:  bad magic

nm:  elfedit.o:  bad magic

nm:  emul_vanilla.o:  bad magic

nm:  filemode.o:  bad magic

nm:  is-ranlib.o:  bad magic

nm:  is-strip.o:  bad magic

nm:  nm.o:  bad magic

nm:  not-ranlib.o:  bad magic

nm:  not-strip.o:  bad magic

nm:  objcopy.o:  bad magic

nm:  objdump.o:  bad magic

nm:  prdbg.o:  bad magic

nm:  rdcoff.o:  bad magic

nm:  rddbg.o:  bad magic

nm:  readelf.o:  bad magic

nm:  rename.o:  bad magic

nm:  size.o:  bad magic

nm:  stabs.o:  bad magic

nm:  strings.o:  bad magic

nm:  sysinfo.o:  bad magic

nm:  syslex_wrap.o:  bad magic

nm:  testglue.o:  bad magic

nm:  unwind-ia64.o:  bad magic

nm:  version.o:  bad magic

nm:  wrstabs.o:  bad magic
-bash-4.4$ file addr2line.o
addr2line.o:PA-RISC1.1 relocatable object

It appears the symbol table is created using magic value for an elf archive. 
This doesn't bother GNU nm, etc, but HP ld can't link executables using
these archives.

--disable-plugins works around the issue but this is not obvious.

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


[Bug binutils/26356] New: FAIL: objcopy --reverse-bytes

2020-08-08 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=26356

Bug ID: 26356
   Summary: FAIL: objcopy --reverse-bytes
   Product: binutils
   Version: 2.35
Status: NEW
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: danglin at gcc dot gnu.org
  Target Milestone: ---
  Host: hppa2.0w-hp-hpux11.11
Target: hppa2.0w-hp-hpux11.11
 Build: hppa2.0w-hp-hpux11.11

/mnt/gnu/binutils/objdir/binutils/objcopy  -j \$DATA\$ --reverse-bytes=4
tmpdir/
bintest.o tmpdir/bintest.o-reversed
Executing on host: /mnt/gnu/binutils/objdir/binutils/objcopy  -j \\$DATA\\$
--re
verse-bytes=4 tmpdir/bintest.o tmpdir/bintest.o-reversed   (timeout = 300)
spawn failed

Program causes segmentation fault.

-bash-4.4$ ./objcopy -j \$DATA\$ --reverse-bytes objcopy.o xxx.o
./objcopy: number of bytes to reverse must be positive and even
-bash-4.4$ ./objcopy -j \$DATA\$ --reverse-bytes=4 objcopy.o xxx.o
Segmentation fault (core dumped)
-bash-4.4$ gdb -c core objcopy
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "hppa2.0w-hp-hpux11.11".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from objcopy...done.
[New process 6052895]

warning: Private mapping of shared library text was not specified
by the executable; setting a breakpoint in a shared library which
is not privately mapped will not work.  See the HP-UX 11i v3 chatr
manpage for methods to privately map shared library text.
Unable to write __dld_flags.
(gdb) bt
#0  som_prep_headers (abfd=0x40014108) at ../../src/bfd/som.c:2678
#1  0x00047fd8 in som_set_section_contents (abfd=0x40014108, section=0x0,
location=0x40027150, offset=0, count=2320) at ../../src/bfd/som.c:5711
#2  0x00036c58 in bfd_set_section_contents (abfd=0x40014108,
section=0x40023fd0, location=0x40027150, offset=0, count=2320)
at ../../src/bfd/section.c:1520
#3  0x00010ca4 in copy_section (ibfd=0x, isection=0x40020e08,
obfdarg=0x40014108) at ../../src/binutils/objcopy.c:4430
#4  0x00036a4c in bfd_map_over_sections (abfd=0x40013048,
operation=@0x400093ca: 0x109c8 , user_storage=0x40014108)
at ../../src/bfd/section.c:1379
#5  0x00012a24 in copy_object (ibfd=0x40013048, obfd=0x40014108,
input_arch=0x4002ff00) at ../../src/binutils/objcopy.c:3266
#6  0x000141fc in copy_file (input_filename=0x7eff0026 "objcopy.o",
output_filename=0x7eff0030 "xxx.o", input_target=0x40014108 "@\002/\240@",
output_target=0x89384 <__PRETTY_FUNCTION__.10416+24> "som", input_arch=0x0)
at ../../src/binutils/objcopy.c:3831
#7  0x00016d5c in main (argc=1818324583, argv=0x6f70742f)
at ../../src/binutils/objcopy.c:5892
(gdb) disass $pc-16,$pc+16
Dump of assembler code from 0x464bc to 0x464dc:
   0x000464bc :   cmpib,=,n 0,ret0,0x465a4

   0x000464c0 :   ldw 4(ret0),ret0
   0x000464c4 :   cmpb,= r3,ret0,0x465bc

   0x000464c8 :   ldo 40(ret0),ret0
=> 0x000464cc :   ldw 0(ret0),ret0
   0x000464d0 :   cmpb,= r3,ret0,0x465bc

   0x000464d4 :   copy r8,r25
   0x000464d8 :   b,l 0x353d8 ,rp
End of assembler dump.
(gdb) p/x $ret0
$1 = 0x40

static bfd_boolean
som_is_space (asection *section)
{
  /* If no copy data is available, then it's neither a space nor a
 subspace.  */
  if (som_section_data (section)->copy_data == NULL)
return FALSE;

  /* If the containing space isn't the same as the given section,
 then this isn't a space.  */
  if (som_section_data (section)->copy_data->container != section
  && (som_section_data (section)->copy_data->container->output_section
  != section))
return FALSE;

  /* OK.  Must be a space.  */
  return TRUE;
}

Looks like som_section_data (section)->copy_data->container is NULL.

This bug has been around for some time.

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