Re: Overloading ld linker script is not working after 2_36

2023-02-14 Thread Alan Modra
On Tue, Feb 14, 2023 at 07:54:29PM +0100, Phil Wiggum wrote:
> I can't get NOLOAD working any more.
> This used to work before binutils_2_36.
> 
> Default linker script 'cc430f5137.ld' is overloaded with a script file 
> (without -T)
> 
> SECTIONS
> {
>   .infoA  (NOLOAD)   : {} > INFOA
>   .infoB  (NOLOAD)   : {} > INFOB
>   .infoC  (NOLOAD)   : {} > INFOC
>   .infoD  (NOLOAD)   : {} > INFOD
> }
> 
> From ld man page:
> If the linker cannot recognize the format of an object file, it
> will assume that it is a linker script.  A script specified in
> this way augments the main linker script used for the link
> (either the default linker script or the one specified by using
> -T).  This feature permits the linker to link against a file
> which appears to be an object or an archive, but actually merely
> defines some symbol values, or uses "INPUT" or "GROUP" to load
> other objects.  Specifying a script in this way merely augments
> the main linker script, with the extra commands placed after the
> main script; use the -T option to replace the default linker
> script entirely, but note the effect of the "INSERT" command.
> 
> Default cc430f5137.ld...
> 
>   .infoA : {} > INFOA   /* MSP430 INFO FLASH MEMORY SEGMENTS */
>   .infoB : {} > INFOB
>   .infoC : {} > INFOC
>   .infoD : {} > INFOD
> 
> 
> Modifying default script with NOLOAD works, but not if I try to overload it.
> 
> 
> msp430-elf-gcc -Wl,--as-needed -Wl,--no-undefined -mmcu=cc430f5137 
> -Wl,--start-group -Wl,--end-group -Wl,--verbose=255 overload-ld/cc430f5137.ld 
> -Wl,-gc-sections -Wl,-Map,cc430f5137.map main.o -o out

I think you've been affected by a deliberate linker change in the
handling of duplicate output sections.  What you'll end up with now
when using your script is overall the same as a single script with

  .infoA : {} > INFOA
...
  .infoA  (NOLOAD)   : {} > INFOA

What that will do is put .infoA sections into the first .infoA output
section seen (by the linker orphan section handling since the script
doesn't have { *(.infoA) }.  This suggests two ways you can fix your
extra linker script.
1) Write ".infoA (NOLOAD) : { *(.infoA) } > INFOA" and similarly for
the other output sections in your extra script.  By specifying the
input sections these will match your output section before orphan
sections are handled.  This modification should work with older
linkers too.
2) Add INSERT BEFORE .infoA; at the end of your extra script.

-- 
Alan Modra
Australia Development Lab, IBM



Issue 55933 in oss-fuzz: binutils:fuzz_nm: Heap-buffer-overflow in _bfd_ecoff_slurp_symbol_table

2023-02-14 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #3 on issue 55933 by sheriffbot: binutils:fuzz_nm: Heap-buffer-overflow 
in _bfd_ecoff_slurp_symbol_table
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55933#c3

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 55870 in oss-fuzz: binutils:fuzz_as: Heap-use-after-free in s_stab_generic

2023-02-14 Thread sheriffbot via monorail
Updates:
Labels: -restrict-view-commit

Comment #3 on issue 55870 by sheriffbot: binutils:fuzz_as: Heap-use-after-free 
in s_stab_generic
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=55870#c3

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 ld/30078] FAIL: merge4

2023-02-14 Thread dave.anglin at bell dot net
https://sourceware.org/bugzilla/show_bug.cgi?id=30078

--- Comment #2 from dave.anglin at bell dot net ---
Hi Nick,

Yes, the behavior of .string on hppa is a bug/feature intended to match the
behavior of HP as.

UsingĀ  .asciz instead of .string fixes the test on hppa.

Dave

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


Overloading ld linker script is not working after 2_36

2023-02-14 Thread Phil Wiggum
I can't get NOLOAD working any more.
This used to work before binutils_2_36.

Default linker script 'cc430f5137.ld' is overloaded with a script file (without 
-T)

SECTIONS
{
  .infoA  (NOLOAD)   : {} > INFOA
  .infoB  (NOLOAD)   : {} > INFOB
  .infoC  (NOLOAD)   : {} > INFOC
  .infoD  (NOLOAD)   : {} > INFOD
}

From ld man page:
If the linker cannot recognize the format of an object file, it
will assume that it is a linker script.  A script specified in
this way augments the main linker script used for the link
(either the default linker script or the one specified by using
-T).  This feature permits the linker to link against a file
which appears to be an object or an archive, but actually merely
defines some symbol values, or uses "INPUT" or "GROUP" to load
other objects.  Specifying a script in this way merely augments
the main linker script, with the extra commands placed after the
main script; use the -T option to replace the default linker
script entirely, but note the effect of the "INSERT" command.

Default cc430f5137.ld...

  .infoA : {} > INFOA   /* MSP430 INFO FLASH MEMORY SEGMENTS */
  .infoB : {} > INFOB
  .infoC : {} > INFOC
  .infoD : {} > INFOD


Modifying default script with NOLOAD works, but not if I try to overload it.


msp430-elf-gcc -Wl,--as-needed -Wl,--no-undefined -mmcu=cc430f5137 
-Wl,--start-group -Wl,--end-group -Wl,--verbose=255 overload-ld/cc430f5137.ld 
-Wl,-gc-sections -Wl,-Map,cc430f5137.map main.o -o out


//Phil



cc430f5137.ld
Description: Binary data


[Bug ld/30078] FAIL: merge4

2023-02-14 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=30078

Nick Clifton  changed:

   What|Removed |Added

 CC||nickc at redhat dot com
 Status|NEW |ASSIGNED
   Assignee|unassigned at sourceware dot org   |nickc at redhat dot com

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

   Just a guess, but I think that this might be a bug/feature of the HPPA
   port of gas:

 % as ld/testsuite/ld-elf/merge4b.s -o merge4b.o
 % readelf -x.rodata.str1.1 merge4b.o
 Hex dump of section '.rodata.str1.1':
   0x 666f6f62 61727768 61746576 6572 foobarwhatever

   Notice how there is no nul-byte between foobar and whatever...  In fact
   there ought to be 2 nul bytes since there is an empty string between
   them:

% cat ld/testsuite/ld-elf/merge4b.s
[...]
.string "foobar"
1:
.string ""
.string "whatever"

   Looking at the assembler sources, it appears that this might be deliberate.
   The default function for handling the .string directive appends a nul byte 
   to the end of the strings, but the HPPA version does not.  (See gas/config/
   tc-hppa.c: md_pseudo_table[]).

   This does suggest a possible workaround - the HPPA port of gas handles the
   .string directive as mentioned above, but it does not handle .asciz.  So if
   the merge4b.s file were to use that directive, the test might work...  Any
   chance that you could test this out ?  (I do not have an HPPA test 
   environment).

Cheers
  Nick

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


[Bug ld/29973] x86_64-w64-mingw32-g++ ld: helloworld.exe:.rdata_r: section below image base for windows

2023-02-14 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29973

--- Comment #31 from Nick Clifton  ---
I am investigating.  But without any way to run newly linked executables,
finding out what is wrong is proving to be quite difficult.

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


[Bug gold/23856] Executables linked with gold against musl segfault at startup

2023-02-14 Thread sam at gentoo dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=23856

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.