https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96455

            Bug ID: 96455
           Summary: Partial Linking (-r) with LTO issue
           Product: gcc
           Version: 9.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dongjianqiang2 at huawei dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Hi, there is a partial linking with lto issue after upgrading gcc7.3.0
(binutils 2.34) to gcc9.3.1 (binutils 2.34).
void bar() {
  return;
}
void foo() {
  return;
}
gcc -flto -o bar.o -c bar.c
gcc -flto -o foo.o -c foo.c
gcc -flto -no-pie -o a.out -Wl,-r bar.o foo.o -nostdlib

gcc 7.3.0 :
readelf -S a.out
Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000000008  0000000000000000  AX       0     0     4
  [ 2] .eh_frame         PROGBITS         0000000000000000  00000048
       000000000000003c  0000000000000000   A       0     0     8
  [ 3] .rela.eh_frame    RELA             0000000000000000  000001e0
       0000000000000030  0000000000000018   I       8     2     8
  [ 4] .data             PROGBITS         0000000000000000  00000084
       0000000000000000  0000000000000000  WA       0     0     1
  [ 5] .bss              NOBITS           0000000000000000  00000084
       0000000000000000  0000000000000000  WA       0     0     1
  [ 6] .comment          PROGBITS         0000000000000000  00000084
       000000000000002b  0000000000000001  MS       0     0     1
  [ 7] .note.GNU-stack   PROGBITS         0000000000000000  000000af
       0000000000000000  0000000000000000           0     0     1
  [ 8] .symtab           SYMTAB           0000000000000000  000000b0
       0000000000000120  0000000000000018           9    10     8
  [ 9] .strtab           STRTAB           0000000000000000  000001d0
       000000000000000f  0000000000000000           0     0     1
  [10] .shstrtab         STRTAB           0000000000000000  00000210
       0000000000000054  0000000000000000           0     0     1

gcc 9.3.1 :
readelf -S a.out
Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000000000000  00000040
       0000000000000000  0000000000000000  AX       0     0     1
  [ 2] .data             PROGBITS         0000000000000000  00000040
       0000000000000000  0000000000000000  WA       0     0     1
  [ 3] .bss              NOBITS           0000000000000000  00000040
       0000000000000000  0000000000000000  WA       0     0     1
  [ 4] .comment          PROGBITS         0000000000000000  00000040
       000000000000003a  0000000000000001  MS       0     0     1
  [ 5] .gnu.lto_.profile PROGBITS         0000000000000000  0000007a
       000000000000000e  0000000000000000   E       0     0     1
  [ 6] .gnu.lto_.icf.553 PROGBITS         0000000000000000  00000088
       000000000000000f  0000000000000000   E       0     0     1
  [ 7] .gnu.lto_.jmpfunc PROGBITS         0000000000000000  00000097
       000000000000001e  0000000000000000   E       0     0     1
  [ 8] .gnu.lto_.inline. PROGBITS         0000000000000000  000000b5
       000000000000002a  0000000000000000   E       0     0     1
  [ 9] .gnu.lto_.purecon PROGBITS         0000000000000000  000000df
       000000000000000e  0000000000000000   E       0     0     1
  [10] .gnu.lto_bar.553c PROGBITS         0000000000000000  000000ed
       00000000000000bc  0000000000000000   E       0     0     1
  [11] .gnu.lto_foo.553c PROGBITS         0000000000000000  000001a9
       00000000000000bb  0000000000000000   E       0     0     1
  [12] .gnu.lto_.symbol_ PROGBITS         0000000000000000  00000264
       000000000000002b  0000000000000000   E       0     0     1
  [13] .gnu.lto_.refs.55 PROGBITS         0000000000000000  0000028f
       000000000000000e  0000000000000000   E       0     0     1
  [14] .gnu.lto_.decls.5 PROGBITS         0000000000000000  0000029d
       00000000000001a7  0000000000000000   E       0     0     1
  [15] .gnu.lto_.symtab. PROGBITS         0000000000000000  00000444
       0000000000000026  0000000000000000   E       0     0     1
  [16] .gnu.lto_.opts    PROGBITS         0000000000000000  0000046a
       000000000000009a  0000000000000000   E       0     0     1
  [17] .note.GNU-stack   PROGBITS         0000000000000000  00000504
       0000000000000000  0000000000000000           0     0     1
  [18] .symtab           SYMTAB           0000000000000000  00000508
       00000000000001e0  0000000000000018          19    18     8
  [19] .strtab           STRTAB           0000000000000000  000006e8
       000000000000001d  0000000000000000           0     0     1
  [20] .shstrtab         STRTAB           0000000000000000  00000705
       00000000000001c8  0000000000000000           0     0     1

Is this a gcc LTO bug?

Reply via email to