Bug 24123 - incremental_copy_test failure when building with gcc-9
Summary: incremental_copy_test failure when building with gcc-9
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-23 01:48 UTC by Alan Modra
Modified: 2020-12-14 01:57 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2019-01-23 01:48:56 UTC
Seen on x86_64-linux with current gcc-9.

gcctestdir/collect-ld: internal error in set_section_addresses, at /home/alan/src/binutils-gdb/gold/output.cc:4441
collect2: error: ld returned 1 exit status
Makefile:9426: recipe for target 'incremental_copy_test' failed
Comment 1 Romain Geissler 2019-02-06 09:54:18 UTC
Hi,

Is it a dup of PR23539 ?

Cheers,
Romain
Comment 2 Alan Modra 2019-02-06 11:22:44 UTC
It may well be the same underlying bug, but .note.gnu.property was not generated by my gcc-9 compiler for any of the incremental_copy_test objects.  (I don't have an Intel CET capable CPU.)
Comment 3 Miguel Saldivar 2020-02-09 04:19:46 UTC
The issue comes from `.rodata` section, as it isn't directly emitted in gcc-9, when using the `-fmerge-constants` flag.

Looking at copy_test_v1.o, produced by gcc-9:
$ readelf --sections copy_test_v1.o
...
  [ 7] .rodata.str1.1
       PROGBITS         0000000000000000  0000000000000100  0
       000000000000002a 0000000000000001  0                 1
       [0000000000000032]: ALLOC, MERGE, STRINGS
  [ 8] .rodata.str1.8
       PROGBITS         0000000000000000  0000000000000130  0
       0000000000000065 0000000000000001  0                 8
       [0000000000000032]: ALLOC, MERGE, STRINGS
...

Now one by gcc-8:
$ readelf --sections copy_test_v1.o
...
  [ 7] .rodata.str1.8
       PROGBITS         0000000000000000  0000000000000100  0
       000000000000004c 0000000000000001  0                 8
       [0000000000000032]: ALLOC, MERGE, STRINGS
  [ 8] .rodata.str1.1
       PROGBITS         0000000000000000  000000000000014c  0
       000000000000001f 0000000000000001  0                 1
       [0000000000000032]: ALLOC, MERGE, STRINGS
  [ 9] .rodata
       PROGBITS         0000000000000000  0000000000000170  0
       000000000000000b 0000000000000000  0                 8
       [0000000000000002]: ALLOC
...

This is the output of `gold` using the `--debug=incremental` flag on the gcc-9 object:
gcctestdir/collect-ld: Free_list::allocate(00000018, 8, 00000540)
gcctestdir/collect-ld: set_section_list_addresses: 00000540 00000018 .rela.plt
gcctestdir/collect-ld: set_section_list_addresses: 000005a8 0000001b .init
gcctestdir/collect-ld: set_section_list_addresses: 000005d0 00000020 .plt
gcctestdir/collect-ld: set_section_list_addresses: 000005f0 00000470 .text
gcctestdir/collect-ld: set_section_list_addresses: 00000a60 0000000d .fini
gcctestdir/collect-ld: set_section_list_addresses: 000001c8 0000001c .interp
gcctestdir/collect-ld: set_section_list_addresses: 00000a70 00000130 .rodata
gcctestdir/collect-ld: set_section_list_addresses: 00000ba0 000000e4 .eh_frame
gcctestdir/collect-ld: Free_list::allocate(00000092, 8, 00000a6d)
gcctestdir/collect-ld: set_section_list_addresses: 00000c88 00000092 .rodata
gcctestdir/collect-ld: Free_list::allocate(00000200, 8, 00000d1a)
gcctestdir/collect-ld: set_section_list_addresses: 00001ad8 00000200 .dynamic
gcctestdir/collect-ld: set_section_list_addresses: 00000eb8 00000040 .got
gcctestdir/collect-ld: set_section_list_addresses: 00000ef8 00000020 .got.plt
gcctestdir/collect-ld: set_section_list_addresses: 00000f18 00000030 .data
gcctestdir/collect-ld: set_section_list_addresses: 00000f48 00000000 .tm_clone_table
gcctestdir/collect-ld: set_section_list_addresses: 00000f48 00000008 .fini_array
gcctestdir/collect-ld: set_section_list_addresses: 00000f50 00000008 .init_array
gcctestdir/collect-ld: internal error in set_section_addresses, at /mnt/hdd/hdd_workspace/binutils-project/build/gold/../../binutils-gdb/gold/output.cc:4453
collect2: error: ld returned 1 exit status

The output using the same flag on `gold`, but instead using the gcc-8 object:
gcctestdir/collect-ld: Free_list::allocate(00000018, 8, 00000540)
gcctestdir/collect-ld: set_section_list_addresses: 00000540 00000018 .rela.plt
gcctestdir/collect-ld: set_section_list_addresses: 000005a8 0000001b .init
gcctestdir/collect-ld: set_section_list_addresses: 000005d0 00000020 .plt
gcctestdir/collect-ld: set_section_list_addresses: 000005f0 00000470 .text
gcctestdir/collect-ld: set_section_list_addresses: 00000a60 0000000d .fini
gcctestdir/collect-ld: set_section_list_addresses: 000001c8 0000001c .interp
gcctestdir/collect-ld: set_section_list_addresses: 00000a70 00000108 .rodata
gcctestdir/collect-ld: set_section_list_addresses: 00000b78 000000e4 .eh_frame
gcctestdir/collect-ld: Free_list::allocate(00000200, 8, 00000c5c)
gcctestdir/collect-ld: set_section_list_addresses: 00000c60 00000200 .dynamic
gcctestdir/collect-ld: set_section_list_addresses: 00000e90 00000040 .got
gcctestdir/collect-ld: set_section_list_addresses: 00000ed0 00000020 .got.plt
gcctestdir/collect-ld: set_section_list_addresses: 00000ef0 00000030 .data
gcctestdir/collect-ld: set_section_list_addresses: 00000f20 00000000 .tm_clone_table
gcctestdir/collect-ld: set_section_list_addresses: 00000f20 00000008 .fini_array
gcctestdir/collect-ld: set_section_list_addresses: 00000f28 00000008 .init_array
gcctestdir/collect-ld: set_section_list_addresses: 00000f30 00000030 .bss

The gcc-9 object output shows two `.rodata` sections being created, and this seems to be the underlying issue.
Comment 4 Sourceware Commits 2020-12-13 23:29:37 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

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

commit f12650bff1a591357c26e0ef6d7be0323f76fdb8
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sun Dec 13 15:19:41 2020 -0800

    Fix incremental linking with rodata merge sections.
    
    When processing the incremental update, incoming .rodata merge sections
    do not match the corresponding section in the base file, because the
    SHF_MERGE flag had not been masked out of the latter.
    
    gold/
            PR gold/24123
            * layout.cc (Layout::init_fixed_output_section): Mask out flags that
            should be ignored when matching sections.
Comment 5 Sourceware Commits 2020-12-14 00:51:02 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

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

commit f22318ef0db86d623e11efbd8936430f38484f69
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Sun Dec 13 16:50:13 2020 -0800

    Re-enable incremental tests that were failing with GCC 9+.
    
    gold/
            PR gold/23539
            PR gold/24123
            * testsuite/Makefile.am (incremental_copy_test): Re-enable for GCC 9+.
            (incremental_comdat_test_1): Likewise.
            * testsuite/Makefile.in: Regenerate.
Comment 6 Cary Coutant 2020-12-14 01:57:07 UTC
Fixed on trunk.