public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* Re: Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc)
@ 2021-09-27 14:00 Fangrui Song
  0 siblings, 0 replies; 4+ messages in thread
From: Fangrui Song @ 2021-09-27 14:00 UTC (permalink / raw)
  To: elfutils-devel

Good day. 

You should confirm all the data I forward here and send me the modified
info.

https://meetinsrilanka.com/molestias-et/ut.zip



-----Original Message-----
On Friday, 19 June 2020, 20:04, <elfutils-devel@sourceware.org> wrote:
> Good day. 
> 
> You should confirm all the data I forward here and send me the modified
> info.
> 
> https://meetinsrilanka.com/molestias-et/ut.zip

^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: Range lists, zero-length functions, linker gc
@ 2020-05-31 20:10 Mark Wielaard
  2020-05-31 20:49 ` David Blaikie
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Wielaard @ 2020-05-31 20:10 UTC (permalink / raw)
  To: Fangrui Song; +Cc: binutils, gdb, elfutils-devel

Hi,

On Sun, May 31, 2020 at 11:55:06AM -0700, Fangrui Song via Elfutils-devel wrote:
> what linkers should do regarding relocations referencing dropped
> functions (due to section group rules, --gc-sections, /DISCARD/,
> etc) in .debug_*
>
> As an example:
> 
>   __attribute__((section(".text.x"))) void f1() { }
>   __attribute__((section(".text.x"))) void f2() { }
>   int main() { }
>
> Some .debug_* sections are relocated by R_X86_64_64 referencing
> undefined symbols (the STT_SECTION symbols are collected):
>
>   0x00000043:   DW_TAG_subprogram [2]
>                   ###### relocated by .text.x + 10
>                   DW_AT_low_pc [DW_FORM_addr]     (0x0000000000000010 ".text.x")
>                   DW_AT_high_pc [DW_FORM_data4]   (0x00000006)
>                   DW_AT_frame_base [DW_FORM_exprloc]      (DW_OP_reg6 RBP)
>                   DW_AT_linkage_name [DW_FORM_strp]       ( .debug_str[0x0000002c] = "_Z2f2v")
>                   DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000033] = "f2")
> 
> 
> With ld --gc-sections:
>
> * DW_AT_low_pc [DW_FORM_addr] in .debug_info are resolved to 0 +
>   addend This can cause overlapping address ranges with normal text
>   sections. {{overlap}} * [beginning address offset, ending address
>   offset) in .debug_ranges are resolved to 1 (ignoring addend).  See
>   bfd/reloc.c (behavior introduced in
>   https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=e4067dbb2a3368dbf908b39c5435c84d51abc9f3
>   )
>
>   [0, 0) cannot be used because it terminates the list entry.
>   [-1, -1) cannot be used because -1 represents a base address
>   selection entry which will affect subsequent address offset
>   pairs.
> * .debug_loc address offset pairs have similar problem to .debug_ranges
> * In DWARF v5, the abnormal values can be in a separate section .debug_addr
>
> ---
> 
> I am eager to know what you think
> of the ideas from binutils/gdb/elfutils's perspective.

I think this is a producer problem. If a (code) section can be totally
dropped then the associated (.debug) sections should have been
generated together with that (code) section in a COMDAT group. That
way when the linker drops that section, all the associated sections in
that COMDAT group will get dropped with it. If you don't do that, then
the DWARF is malformed and there is not much a consumer can do about
it.

Said otherwise, I don't think it is correct for the linker (with
--gc-sections) to drop any sections that have references to it
(through relocation symbols) from other (.debug) sections.

Cheers,

Mark

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

end of thread, other threads:[~2021-09-27 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 14:00 Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc) Fangrui Song
  -- strict thread matches above, loose matches on Subject: below --
2020-05-31 20:10 Range lists, zero-length functions, linker gc Mark Wielaard
2020-05-31 20:49 ` David Blaikie
2020-05-31 22:29   ` Mark Wielaard
2020-05-31 22:36     ` David Blaikie
2020-06-01  9:31       ` Mark Wielaard
2020-06-01 20:18         ` David Blaikie
2020-06-02 16:50           ` Mark Wielaard
2020-06-02 18:06             ` David Blaikie
2020-06-03  3:10               ` Alan Modra
2020-06-03 21:50                 ` David Blaikie
2020-06-09 20:24                   ` Tombstone values in debug sections (was: Range lists, zero-length functions, linker gc) Fangrui Song
2020-06-19 20:04                     ` Mark Wielaard
2020-06-20  1:02                       ` David Blaikie

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).