[Bug ld/29807] SIGSEGV when linking fuzzed PE object

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29807

--- Comment #4 from Stas Sergeev  ---
Created attachment 14466
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14466&action=edit
reduced test-case

I reduced the test-case to bare minimum.
No fancy binary blobs this time!
Just run "make" and it will build an
example to segfault.

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


[Bug ld/29761] relocatable linking loses some symbols

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29761

Stas Sergeev  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #9 from Stas Sergeev  ---
Lets reopen to not forget the re-check.
Please close if the new test-case is also
fixed by the prev patch.

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


[Bug ld/29807] SIGSEGV when linking fuzzed PE object

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29807

--- Comment #5 from Stas Sergeev  ---
I suggest removing "fuzzed" from
the description as it suggests I
did something malicious to the objects.
Last test-case shows I didn't, as
it generates an objects from source.

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


[Bug ld/29807] objcopy converts ELF relocatable object to PE that cause a ld segfault

2022-11-19 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29807

Alan Modra  changed:

   What|Removed |Added

Summary|SIGSEGV when linking fuzzed |objcopy converts ELF
   |PE object   |relocatable object to PE
   ||that cause a ld segfault

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


[Bug ld/29808] New: --no-allow-shlib-undefined seems to be ignored

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29808

Bug ID: 29808
   Summary: --no-allow-shlib-undefined seems to be ignored
   Product: binutils
   Version: 2.39
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: stsp at users dot sourceforge.net
  Target Milestone: ---

void foo(void);

int main()
{
foo();
return 0;
}


$ gcc -shared -Wl,--no-allow-shlib-undefined -o libmain.so main.c
produces no error.
Things like --no-undefined seems to work
also for shlibs though.
If this is a documentation error, please fix
the documentation. :)

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


[Bug binutils/29809] New: strip strips too much from relocatable objects

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29809

Bug ID: 29809
   Summary: strip strips too much from relocatable objects
   Product: binutils
   Version: 2.39
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: stsp at users dot sourceforge.net
  Target Milestone: ---

Created attachment 14467
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14467&action=edit
test case

Attached is a simple test-case.
strip removes "main" so linking then
fails.

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


[Bug ld/29802] Segmentation fault in _bfd_elf_strtab_add

2022-11-19 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=29802

--- Comment #5 from John David Anglin  ---
libtool: link: /home/dave/gnu/gcc/objdir64/./gcc/xgcc
-B/home/dave/gnu/gcc/objdi
r64/./gcc/ -B/opt/gnu64/gcc_gld/gcc-13/hppa64-hp-hpux11.11/bin/
-B/opt/gnu64/gcc
_gld/gcc-13/hppa64-hp-hpux11.11/lib/ -isystem
/opt/gnu64/gcc_gld/gcc-13/hppa64-h
p-hpux11.11/include -isystem
/opt/gnu64/gcc_gld/gcc-13/hppa64-hp-hpux11.11/sys-i
nclude-shared  math/.libs/x2y2m1q.o math/.libs/acoshq.o math/.libs/fmodq.o
m
ath/.libs/acosq.o math/.libs/frexpq.o math/.libs/rem_pio2q.o
math/.libs/asinhq.o
 math/.libs/hypotq.o math/.libs/remainderq.o math/.libs/asinq.o
math/.libs/rintq
.o math/.libs/atan2q.o math/.libs/isinfq.o math/.libs/roundq.o
math/.libs/atanhq
.o math/.libs/isnanq.o math/.libs/scalblnq.o math/.libs/atanq.o
math/.libs/j0q.o math/.libs/scalbnq.o math/.libs/cbrtq.o math/.libs/j1q.o
math/.libs/signbitq.o math/.libs/ceilq.o math/.libs/jnq.o
math/.libs/sincos_table.o math/.libs/complex.o math/.libs/ldexpq.o
math/.libs/sincosq.o math/.libs/copysignq.o math/.libs/lgammaq.o
math/.libs/sincosq_kernel.o math/.libs/coshq.o math/.libs/llroundq.o
math/.libs/sinhq.o math/.libs/cosq.o math/.libs/log10q.o math/.libs/sinq.o
math/.libs/cosq_kernel.o math/.libs/log1pq.o math/.libs/sinq_kernel.o
math/.libs/erfq.o math/.libs/logq.o math/.libs/sqrtq.o math/.libs/expm1q.o
math/.libs/lroundq.o math/.libs/tanhq.o math/.libs/expq.o math/.libs/modfq.o
math/.libs/tanq.o math/.libs/fabsq.o math/.libs/nanq.o math/.libs/tgammaq.o
math/.libs/finiteq.o math/.libs/nextafterq.o math/.libs/truncq.o
math/.libs/floorq.o math/.libs/powq.o math/.libs/fmaq.o math/.libs/logbq.o
math/.libs/exp2q.o math/.libs/issignalingq.o math/.libs/lgammaq_neg.o
math/.libs/lgammaq_product.o math/.libs/tanq_kernel.o
math/.libs/tgammaq_product.o math/.libs/casinhq_kernel.o math/.libs/cacoshq.o
math/.libs/cacosq.o math/.libs/casinhq.o math/.libs/casinq.o
math/.libs/catanhq.o math/.libs/catanq.o math/.libs/cimagq.o math/.libs/conjq.o
math/.libs/cprojq.o math/.libs/crealq.o math/.libs/fdimq.o math/.libs/fmaxq.o
math/.libs/fminq.o math/.libs/ilogbq.o math/.libs/llrintq.o math/.libs/log2q.o
math/.libs/lrintq.o math/.libs/nearbyintq.o math/.libs/remquoq.o
math/.libs/ccoshq.o math/.libs/cexpq.o math/.libs/clog10q.o math/.libs/clogq.o
math/.libs/csinq.o math/.libs/csinhq.o math/.libs/csqrtq.o math/.libs/ctanq.o
math/.libs/ctanhq.o printf/.libs/addmul_1.o printf/.libs/add_n.o
printf/.libs/cmp.o printf/.libs/divrem.o printf/.libs/flt1282mpn.o
printf/.libs/fpioconst.o printf/.libs/lshift.o printf/.libs/mul_1.o
printf/.libs/mul_n.o printf/.libs/mul.o printf/.libs/printf_fphex.o
printf/.libs/printf_fp.o printf/.libs/quadmath-printf.o printf/.libs/rshift.o
printf/.libs/submul_1.o printf/.libs/sub_n.o strtod/.libs/strtoflt128.o
strtod/.libs/mpn2flt128.o strtod/.libs/tens_in_limb.o   -lm -lc 
-Wl,--version-script=../../../gcc/libquadmath/quadmath.map   -Wl,-soname
-Wl,libquadmath.sl.0 -o .libs/libquadmath.sl.0.0
/opt/gnu64/bin/ld: warning: /lib/pa20_64/libm.sl has a section extending past
end of file
/opt/gnu64/bin/ld: /lib/pa20_64/libm.sl: .dynsym local symbol at index 0 (>=
sh_info of 0)
/opt/gnu64/bin/ld: /lib/pa20_64/libm.sl: .dynsym local symbol at index 1 (>=
sh_info of 0)
/opt/gnu64/bin/ld: /lib/pa20_64/libm.sl: .dynsym local symbol at index 2 (>=
sh_info of 0)
/opt/gnu64/bin/ld: /lib/pa20_64/libm.sl: .dynsym local symbol at index 3 (>=
sh_info of 0)
/opt/gnu64/bin/ld: warning: /lib/pa20_64/libc.sl has a section extending past
end of file
/opt/gnu64/bin/ld: /lib/pa20_64/libc.sl: .dynsym local symbol at index 0 (>=
sh_info of 0)
/opt/gnu64/bin/ld: /lib/pa20_64/libc.sl: .dynsym local symbol at index 1 (>=
sh_info of 0)
/opt/gnu64/bin/ld: /lib/pa20_64/libc.sl: .dynsym local symbol at index 2 (>=
sh_info of 0)
/opt/gnu64/bin/ld: /lib/pa20_64/libc.sl: .dynsym local symbol at index 3 (>=
sh_info of 0)
/opt/gnu64/bin/ld: math/.libs/sincos_table.o: invalid string offset 58 >= 32
for section `.strtab'
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core
dumped
compilation terminated.
make[3]: *** [Makefile:829: libquadmath.la] Error 1

(gdb) frame 1
#1  0x400fa1b4 in bfd_elf_link_record_local_dynamic_symbol (
info=0x80010001b238 , input_bfd=0x8001001db158,
input_indx=44) at ../../src/bfd/elflink.c:841
841   dynstr_index = _bfd_elf_strtab_add (dynstr, name, false);
(gdb) p *entry
$1 = {next = 0x0, input_bfd = 0x0, input_indx = 0, dynindx = 0, isym = {
st_value = 64, st_size = 0, st_name = 58, st_info = 0 '\000',
st_other = 0 '\000', st_target_internal = 0 '\000', st_shndx = 4}}

bash-5.1$ readelf -at
./hppa64-hp-hpux11.11/libquadmath/math/.libs/sincos_table.o
ELF Header:
  Magic:   7f 45 4c 46 02 02 01 01 01 00 00 00 00 00 00 00
  Class: ELF64
  Data:  2's complement, big endian
  Version:   1 (current)
  OS/ABI:UNIX - HP-UX

[Bug binutils/29810] New: objcopy to pe-i386 corrupts relocations

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29810

Bug ID: 29810
   Summary: objcopy to pe-i386 corrupts relocations
   Product: binutils
   Version: 2.39
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: stsp at users dot sourceforge.net
  Target Milestone: ---

Created attachment 14468
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14468&action=edit
test case

Attached test-case shows that the
program can be compiled correctly
directly to PE - use "make good"
for that.
To demonstrate the bug, use "make bad" -
in that case an extra step is added,
such as the source is compiled to elf
first and then converted to PE with
objcopy.
The test-case manages to avoid the linker crash
https://sourceware.org/bugzilla/show_bug.cgi?id=29807
by using strip, and it manages to avoid
https://sourceware.org/bugzilla/show_bug.cgi?id=29809
by using "strip --strip-debug".
At the end, linking fails complaining to
the "0-bit reloc in dll":

i686-w64-mingw32-gcc hel.o prnt.o -o bad.exe
/usr/bin/i686-w64-mingw32-ld: error: 0-bit reloc in dll
/usr/bin/i686-w64-mingw32-ld: error: 0-bit reloc in dll
/usr/bin/i686-w64-mingw32-ld: error: 0-bit reloc in dll
/usr/bin/i686-w64-mingw32-ld: error: 0-bit reloc in dll
collect2: error: ld returned 1 exit status
make: *** [Makefile:14: bad.exe] Error 1

The test case uses mingw for convenience, but
the same error happens invoking ld directly:

$ ld -mi386pe hel.o prnt.o -o bad.exe
ld: error: 0-bit reloc in dll
ld: error: 0-bit reloc in dll
ld: error: 0-bit reloc in dll
ld: error: 0-bit reloc in dll

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


[Bug ld/29802] Segmentation fault in _bfd_elf_strtab_add

2022-11-19 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=29802

--- Comment #6 from John David Anglin  ---
bash-5.1$ readelf -x 15 ./math/.libs/sincos_table.o

Hex dump of section '.strtab':
  0x 0073696e 636f735f 7461626c 652e6300 .sincos_table.c.
  0x0010 5f5f7369 6e636f73 715f7461 626c6500 __sincosq_table.

sincos_table.o was assembled with gas.

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


[Bug binutils/29809] strip strips too much from relocatable objects

2022-11-19 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29809

Alan Modra  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |NOTABUG

--- Comment #1 from Alan Modra  ---
strip is working as intended.  Don't strip relocatable object files if you need
access to their symbols!

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


[Bug ld/29802] Segmentation fault in _bfd_elf_strtab_add

2022-11-19 Thread danglin at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=29802

--- Comment #7 from John David Anglin  ---
Created attachment 14469
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14469&action=edit
sincos_table.s

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


[Bug binutils/29809] strip strips too much from relocatable objects

2022-11-19 Thread stsp at users dot sourceforge.net
https://sourceware.org/bugzilla/show_bug.cgi?id=29809

--- Comment #2 from Stas Sergeev  ---
(In reply to Alan Modra from comment #1)
> Don't strip relocatable object files if you
> need access to their symbols!

Are the resulting objects useful for anything at all?
Is the intentional behavior documented?

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


[Bug binutils/29810] objcopy to pe-i386 corrupts relocations

2022-11-19 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29810

Alan Modra  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #1 from Alan Modra  ---
>From the objcopy man page:
"However, copying a relocatable object file between any two formats may not
work as expected."

It's worse than that really.  The truth is that objcopy can't be used to
translate relocations from one format to another.

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


[Bug ld/29808] --no-allow-shlib-undefined seems to be ignored

2022-11-19 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29808

Alan Modra  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Alan Modra  ---
--no-allow-shlib-undefined tells the linker to complain if there are unresolved
symbols from shared libraries being linked against.  You have an unresolved
symbol in a relocatable object.

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


[Bug binutils/13256] AR + plugin fails with "no operation specified" error

2022-11-19 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=13256

Sam James  changed:

   What|Removed |Added

 CC||sam at gentoo dot org

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