bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/28124] New: ld: Make special sections in a section group GCable


From: i at maskray dot me
Subject: [Bug ld/28124] New: ld: Make special sections in a section group GCable
Date: Fri, 23 Jul 2021 03:29:04 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=28124

            Bug ID: 28124
           Summary: ld: Make special sections in a section group GCable
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: i at maskray dot me
  Target Milestone: ---

% cat a.s
.globl _start, bbb
_start:

.section .mytext.bbb,"axG",@progbits,bbb,comdat
bbb:
.byte 0

.section .init_array.bbb,"awG",@init_array,bbb,comdat
.byte 0
% cc -c a.s && ld.bfd --gc-sections --print-gc-sections a.o
(no output)

If I rename .init_array.bbb to .myinit_array.bbb, the group can be GCed

% cc -c a.s && ld.bfd --gc-sections --print-gc-sections a.o
ld.bfd: removing unused section '.group' in file 'a.o'
ld.bfd: removing unused section '.mytext.bbb[bbb]' in file 'a.o'
ld.bfd: removing unused section '.myinit_array.bbb[bbb]' in file 'a.o'

It seems favorable to make all special sections GCable if in a section group.
This makes the rule more consistent.

An SHF_ALLOC SHT_NOTE appears to be a GC root outside of a group.

---

Before 13.0,
clang -fsanitize-coverage=... abuses .init_array.2 (SHT_INIT_ARRAY) in a
section group to make the group a GC root, e.g.

% clang -fsanitize-coverage=trace-pc-guard -c -xc++ =(printf 'int main(){}')
-ffunction-sections -fdata-sections -c -o a.o
% readelf -Wg a.o

group section [    3] `.group' [main] contains 3 sections:
   [Index]    Name
   [    4]   .text.main
   [    5]   .rela.text.main
   [    9]   __sancov_guards

COMDAT group section [    6] `.group' [sancov.module_ctor_trace_pc_guard]
contains 4 sections:
   [Index]    Name
   [    7]   .text.sancov.module_ctor_trace_pc_guard
   [    8]   .rela.text.sancov.module_ctor_trace_pc_guard
   [   10]   .init_array.2
   [   11]   .rela.init_array.2

The intention is that .text.sancov.module_ctor_trace_pc_guard will be retained.

I changed 13.0.0 to use SHF_GNU_RETAIN to express the GC root intention
explicitly.
You may consider work around it, but I think not working around it is also
fine.

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]