[PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag
H.J. Lu
hjl.tools@gmail.com
Wed Sep 30 22:13:15 GMT 2020
More information about the Binutils mailing list
Wed Sep 30 22:13:15 GMT 2020
- Previous message (by thread): [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag
- Next message (by thread): how to set .bss section type to PROGBITS within linker script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Sep 28, 2020 at 6:28 AM Jozef Lawrynowicz <jozef.l@mittosystems.com> wrote: > > The attached patch is version 2 of the SHF_GNU_RETAIN patch that was > previously discussed here: > https://sourceware.org/pipermail/binutils/2020-September/113406.html > > The following changes have been made: > - Removed the .retain directive > - The assembler will create different input sections for sections with > the same name but SHF_GNU_RETAIN set/unset (thanks to H.J. for that). > This means the linker will be able to do a better job garbage > collecting input sections, as the "retain" attribute applied to a > symbol declaration in the source code will not cause other parts of > the program that are not required, but are in the same section, to be > unnecessarily retained. > - Added GNU OSABI handling (also thanks to H.J.). > > I've successfully regtested the patch for the Binutils, GAS and LD > testsuites for the following targets: > > aarch64-elf arc-elf arm-eabi arm-elf avr-elf bfin-elf cr16-elf cris-elf > crx-elf csky-elf d10v-elf d30v-elf dlx-elf epiphany-elf fr30-elf frv-elf > ft32-elf h8300-elf hppa-elf i386-elf ip2k-elf iq2000-elf lm32-elf > m32c-elf m32r-elf m68hc11-elf m68hc12-elf m68k-elf mcore-elf mep-elf > metag-elf microblaze-elf mips-elf moxie-elf msp430-elf mt-elf nios2-elf > or1k-elf pj-elf ppc-elf pru-elf riscv-elf rl78-elf rx-elf s12z-elf > score-elf sh-elf sparc-elf spu-elf tic6x-elf tilegx-elf tilepro-elf > v850-elf visium-elf wasm32-elf xgate-elf xstormy16-elf xtensa-elf > z80-elf. > > The new tests only run for the targets that use the GNU OSABI. From the > above list, arm-elf, hppa-elf, msp430-elf, visium-elf do not use the GNU > OSABI, so do not support SHF_GNU_RETAIN. > > Ok to apply? > > Thanks, > Jozef +# SHF_GNU_RETAIN requires the GNU OSABI. +if { [check_gc_sections_available] && [supports_gnu_osabi] } { + run_ld_link_tests [list \ + [list "SHF_GNU_RETAIN 1" \ + "--gc-sections -e _start --print-gc-sections" "" "" \ + {retain1.s} \ + {{ ld retain1.msg }} \ + "retain1.exe"] \ + [list "SHF_GNU_RETAIN 3 (keep sections referenced by retained sections)" \ + "--gc-sections -e _start --print-gc-sections" "" "" \ + {retain3.s} {} \ + "retain3.exe"] \ + [list "SHF_GNU_RETAIN 4 (keep orphaned sections when not discarding)" \ + "--gc-sections -e _start --print-gc-sections --orphan-handling=place" "" "" \ + {retain4.s} {} \ + "retain4.exe"] \ + [list "Build libretain5.a" \ + "" "" "" \ + {retain5lib.s} {} "libretain5.a"] \ + [list "SHF_GNU_RETAIN 5 (don't pull SHF_GNU_RETAIN section out of lib)" \ + "--gc-sections -e _start --print-gc-sections" "-Ltmpdir -lretain5" "" \ + {retain5main.s} {} \ + "retain5.exe"] \ + [list "Build libretain6.a" \ + "" "" "" \ + {retain6lib.s} {} "libretain6.a"] \ + [list "SHF_GNU_RETAIN 6 (pull section out of lib required by SHF_GNU_RETAIN section)" \ + "--gc-sections -e _start --print-gc-sections" "-Ltmpdir -lretain6" "" \ + {retain6main.s} \ + {{ ld retain6.msg }} \ + "retain6.exe"] \ + ] +} + Can you use *.d files like retain6.d: #ld: --gc-sections --print-gc-sections -e _start #warning_output: retain6.l #target: [check_gc_sections_available] instead? -- H.J.
- Previous message (by thread): [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag
- Next message (by thread): how to set .bss section type to PROGBITS within linker script
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list