public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
@ 2021-02-02 23:59 manojgupta at google dot com
  2021-02-03  1:27 ` [Bug debug/98946] " manojgupta at google dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: manojgupta at google dot com @ 2021-02-02 23:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98946
           Summary: GCC generating incorrect relocation R_386_GOTOFF in
                    .debug-info for x86 (32)
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manojgupta at google dot com
  Target Milestone: ---

Created attachment 50116
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50116&action=edit
pre-processed files and gcc command limes

This might be related to an older bug 82630 that fixed a similar issue for
R_386_GOTPC relocations.

Chromium OS bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1171829

We are hitting a similar problem when upgrading to GCC 10.2.1 in Chrome OS. the
affected files are in glibc 2.27 where the presence of R_386_GOTOFF is causing
LLD linker to complain. This is breaking static linking on 32-bit for us.

The errors look like:
ld.lld: error: dl-close.c:(.debug_info+0x1E6A): has non-ABS relocation
R_386_GOTOFF against symbol '.LC3'
ld.lld: error: dl-profile.c:(.debug_info+0x1A7C): has non-ABS relocation
R_386_GOTOFF against symbol '.LC4'
ld.lld: error: dl-lookup.c:(.debug_info+0x23FA): has non-ABS relocation
R_386_GOTOFF against symbol '.LC8'
ld.lld: error: dl-reloc.c:(.debug_info+0x3555): has non-ABS relocation
R_386_GOTOFF against symbol '.LC7'
ld.lld: error: dl-load.c:(.debug_info+0x1B1C): has non-ABS relocation
R_386_GOTOFF against symbol '.LC65'
ld.lld: error: malloc.c:(.debug_info+0x28D5): has non-ABS relocation
R_386_GOTOFF against symbol '.LC2'
ld.lld: error: plural.c:(.debug_loc+0xFA4): has non-ABS relocation R_386_GOTOFF
against symbol 'yyr2'

It was suggested on the bug by Fangrui who is our LLD expert that this might be
a GCC bug.
"Relocations from .debug_info referencing .text.* can only be absolute
relocation types or DTPREL (TLS)-like."

There was a previous fix for a similar bug:
https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=6b10f1741a1d79c9e32e8790fb98ba93c864b219
. Maybe the fix needs to be extended to handle the R_386_GOTOFF relocations.

I am attaching one of the files LLD is complaining (dl-close.c) with
intermediate steps and output of "-v" command line. The assembler being used is
GNU assembler 2.35.1.

Please let me know if more information is needed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/98946] GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
  2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
@ 2021-02-03  1:27 ` manojgupta at google dot com
  2021-02-03  2:40 ` manojgupta at google dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: manojgupta at google dot com @ 2021-02-03  1:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Manoj Gupta <manojgupta at google dot com> ---
For ease of search, the problem I think lies at Line 6957 of dl-close.s.
dl-close.s file line 6957:
         .long   .LC3@gotoff
It is part of .debug_info section and it has GOTOFF relocation

This matches the LLD complain:
ld.lld: error: dl-close.c:(.debug_info+0x1E6A): has non-ABS relocation
R_386_GOTOFF against symbol '.LC3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/98946] GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
  2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
  2021-02-03  1:27 ` [Bug debug/98946] " manojgupta at google dot com
@ 2021-02-03  2:40 ` manojgupta at google dot com
  2021-02-03  7:49 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: manojgupta at google dot com @ 2021-02-03  2:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Manoj Gupta <manojgupta at google dot com> ---
Created attachment 50117
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50117&action=edit
dl-close.s file generated by GCC

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/98946] GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
  2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
  2021-02-03  1:27 ` [Bug debug/98946] " manojgupta at google dot com
  2021-02-03  2:40 ` manojgupta at google dot com
@ 2021-02-03  7:49 ` rguenth at gcc dot gnu.org
  2021-02-03  7:50 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-03  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |10.2.1, 11.0, 9.3.1
           Keywords|                            |wrong-debug
   Last reconfirmed|                            |2021-02-03
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed with -O2 -g -fPIE.  GCC 7 produces

        .uleb128 0x42   # (DIE (0x5789) DW_TAG_GNU_call_site_parameter)
        .uleb128 0x2    # DW_AT_location
        .byte   0x74    # DW_OP_breg4
        .sleb128 0
        .uleb128 0xf    # DW_AT_GNU_call_site_value
        .byte   0x91    # DW_OP_fbreg
        .sleb128 -60
        .byte   0x6     # DW_OP_deref
        .byte   0x3     # DW_OP_addr
        .long   _GLOBAL_OFFSET_TABLE_
        .byte   0x1c    # DW_OP_minus
        .byte   0x3     # DW_OP_addr
        .long   .LC3
        .byte   0x22    # DW_OP_plus
        .byte   0       # end of children of DIE 0x5780
        .byte   0       # end of children of DIE 0x4f2c

not sure if that's any better ...

GCC 10 variant:

        .uleb128 0x35   # (DIE (0x2aeb) DW_TAG_GNU_call_site_parameter)
        .uleb128 0x2    # DW_AT_location
        .byte   0x74    # DW_OP_breg4
        .sleb128 0
        .uleb128 0x9    # DW_AT_GNU_call_site_value
        .byte   0x91    # DW_OP_fbreg
        .sleb128 -60
        .byte   0x6     # DW_OP_deref
        .byte   0x3     # DW_OP_addr
        .long   .LC3@gotoff
        .byte   0x22    # DW_OP_plus
        .byte   0       # end of children of DIE 0x2ade

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/98946] GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
  2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
                   ` (2 preceding siblings ...)
  2021-02-03  7:49 ` rguenth at gcc dot gnu.org
@ 2021-02-03  7:50 ` rguenth at gcc dot gnu.org
  2021-02-03  7:57 ` jakub at gcc dot gnu.org
  2021-02-04  2:49 ` manojgupta at google dot com
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-02-03  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> Confirmed with -O2 -g -fPIE

plus -march=atom -m32

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/98946] GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
  2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
                   ` (3 preceding siblings ...)
  2021-02-03  7:50 ` rguenth at gcc dot gnu.org
@ 2021-02-03  7:57 ` jakub at gcc dot gnu.org
  2021-02-04  2:49 ` manojgupta at google dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-02-03  7:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
No, that is a lld bug, there is no such rule that would say these relocations
can't be applied against non-allocated or debug sections.
GCC var-tracking figures out that the last argument passed to __assert_fail is
equivalent to %ebx + __PRETTY_FUNCTION__.0@gotoff, but can't prove that %ebx
will be equal to __GLOBAL_OFFSET_TABLE__, so can't emit there just
__PRETTY_FUNCTION__.0 - while %ebx must be some __GLOBAL_OFFSET_TABLE__
pointer, it could have been adjusted, so e.g. it could be
__GLOBAL_OFFSET_TABLE__ + index and the needed value would then be
__PRETTY_FUNCTION__.0 + index.
And we want to emit as compact debug info as possible, so emitting it as
%ebx + __PRETTY_FUNCTION__.0@gotoff rather than say (%ebx -
__GLOBAL_OFFSET_TABLE__) + __PRETTY_FUNCTION__.0, especially because
referencing __GLOBAL_OFFSET_TABLE__ symbol in assembly poses interesting
problem (implies special relocations).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug debug/98946] GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32)
  2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
                   ` (4 preceding siblings ...)
  2021-02-03  7:57 ` jakub at gcc dot gnu.org
@ 2021-02-04  2:49 ` manojgupta at google dot com
  5 siblings, 0 replies; 7+ messages in thread
From: manojgupta at google dot com @ 2021-02-04  2:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Manoj Gupta <manojgupta at google dot com> ---
Thanks Jakub for the detailed information.

Fangrui has kindly provided a LLD fix at https://reviews.llvm.org/D95994

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-04  2:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 23:59 [Bug debug/98946] New: GCC generating incorrect relocation R_386_GOTOFF in .debug-info for x86 (32) manojgupta at google dot com
2021-02-03  1:27 ` [Bug debug/98946] " manojgupta at google dot com
2021-02-03  2:40 ` manojgupta at google dot com
2021-02-03  7:49 ` rguenth at gcc dot gnu.org
2021-02-03  7:50 ` rguenth at gcc dot gnu.org
2021-02-03  7:57 ` jakub at gcc dot gnu.org
2021-02-04  2:49 ` manojgupta at google dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).