Browse Source
2020-12-14 H.J. Lu <hjl.tools@gmail.com>
Cary Coutant <ccoutant@gmail.com>
elfcpp/
PR gold/27039
* elfcpp.h (SHF): Add SHF_GNU_RETAIN.
gold/
PR gold/27039
* layout.cc (Layout::layout): Strip SHF_GNU_RETAIN.
* object.cc (Sized_relobj_file::Sized_relobj_file): Initialize osabi_.
(Sized_relobj_file::do_layout): Keep SHF_GNU_RETAIN sections for
GNU/FreBSD ELFOSABIs.
* object.h (Osabi) New class.
(Sized_relobj_file): Add osabi() and osabi_.
* testsuite/Makefile.am (check_SCRIPTS): Add retain.sh.
(check_DATA): Add retain_1.out retain_2.out.
(MOSTLYCLEANFILES): Add retain_1 retain_2.
(retain_1.out): New target.
(retain_1): Likewise.
(retain_1.o): Likewise.
(retain_2.out): Likewise.
(retain_2): Likewise.
(retain_2.o): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/retain.sh: New file.
* testsuite/retain_1.s: Likewise.
* testsuite/retain_2.s: Likewise.
binutils-2_36-branch
9 changed files with 294 additions and 20 deletions
@ -0,0 +1,60 @@ |
|||
#!/bin/sh |
|||
|
|||
# retain.sh -- Tests for SHF_GNU_RETAIN. |
|||
|
|||
# Copyright (C) 2020 Free Software Foundation, Inc. |
|||
|
|||
# This file is part of gold. |
|||
|
|||
# This program is free software; you can redistribute it and/or modify |
|||
# it under the terms of the GNU General Public License as published by |
|||
# the Free Software Foundation; either version 3 of the License, or |
|||
# (at your option) any later version. |
|||
|
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
|
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
|||
# MA 02110-1301, USA. |
|||
|
|||
set -e |
|||
|
|||
check() |
|||
{ |
|||
number_of_occurrence=`egrep "$2" ./$1 -o | wc -l` |
|||
if [ $number_of_occurrence != $3 ] |
|||
then |
|||
echo "$1: \"$2\" $3: Failed" |
|||
status=1 |
|||
fi |
|||
} |
|||
|
|||
status=0 |
|||
check retain_1.out " T fnretain1" 1 |
|||
check retain_1.out " b lsretain0.2" 1 |
|||
check retain_1.out " b lsretain1.1" 1 |
|||
check retain_1.out " d lsretain2.0" 1 |
|||
check retain_1.out " B retain0" 1 |
|||
check retain_1.out " B retain1" 1 |
|||
check retain_1.out " D retain2" 1 |
|||
check retain_1.out " b sretain0" 1 |
|||
check retain_1.out " b sretain1" 1 |
|||
check retain_1.out " d sretain2" 1 |
|||
if grep discard retain_1.out |
|||
then |
|||
echo "retain_1.out: Garbage collection failed" |
|||
status=1 |
|||
fi |
|||
|
|||
check retain_2.out " \(PREINIT_ARRAY\)" 1 |
|||
check retain_2.out " \(PREINIT_ARRAYSZ\)" 1 |
|||
check retain_2.out " \(INIT_ARRAY\)" 1 |
|||
check retain_2.out " \(INIT_ARRAYSZ\)" 1 |
|||
check retain_2.out " \(FINI_ARRAY\)" 1 |
|||
check retain_2.out " \(FINI_ARRAYSZ\)" 1 |
|||
|
|||
exit $status |
|||
@ -0,0 +1,104 @@ |
|||
.global discard0 |
|||
.section .bss.discard0,"aw" |
|||
.type discard0, %object |
|||
discard0: |
|||
.zero 2 |
|||
|
|||
.global discard1 |
|||
.section .bss.discard1,"aw" |
|||
.type discard1, %object |
|||
discard1: |
|||
.zero 2 |
|||
|
|||
.global discard2 |
|||
.section .data.discard2,"aw" |
|||
.type discard2, %object |
|||
discard2: |
|||
.word 1 |
|||
|
|||
.section .bss.sdiscard0,"aw" |
|||
.type sdiscard0, %object |
|||
sdiscard0: |
|||
.zero 2 |
|||
|
|||
.section .bss.sdiscard1,"aw" |
|||
.type sdiscard1, %object |
|||
sdiscard1: |
|||
.zero 2 |
|||
|
|||
.section .data.sdiscard2,"aw" |
|||
.type sdiscard2, %object |
|||
sdiscard2: |
|||
.word 1 |
|||
|
|||
.section .text.fndiscard0,"ax" |
|||
.global fndiscard0 |
|||
.type fndiscard0, %function |
|||
fndiscard0: |
|||
.word 0 |
|||
|
|||
.global retain0 |
|||
.section .bss.retain0,"awR" |
|||
.type retain0, %object |
|||
retain0: |
|||
.zero 2 |
|||
|
|||
.global retain1 |
|||
.section .bss.retain1,"awR" |
|||
.type retain1, %object |
|||
retain1: |
|||
.zero 2 |
|||
|
|||
.global retain2 |
|||
.section .data.retain2,"awR" |
|||
.type retain2, %object |
|||
retain2: |
|||
.word 1 |
|||
|
|||
.section .bss.sretain0,"awR" |
|||
.type sretain0, %object |
|||
sretain0: |
|||
.zero 2 |
|||
|
|||
.section .bss.sretain1,"awR" |
|||
.type sretain1, %object |
|||
sretain1: |
|||
.zero 2 |
|||
|
|||
.section .data.sretain2,"aRw" |
|||
.type sretain2, %object |
|||
sretain2: |
|||
.word 1 |
|||
|
|||
.section .text.fnretain1,"Rax" |
|||
.global fnretain1 |
|||
.type fnretain1, %function |
|||
fnretain1: |
|||
.word 0 |
|||
|
|||
.section .text.fndiscard2,"ax" |
|||
.global fndiscard2 |
|||
.type fndiscard2, %function |
|||
fndiscard2: |
|||
.word 0 |
|||
|
|||
.section .bss.lsretain0,"awR" |
|||
.type lsretain0.2, %object |
|||
lsretain0.2: |
|||
.zero 2 |
|||
|
|||
.section .bss.lsretain1,"aRw" |
|||
.type lsretain1.1, %object |
|||
lsretain1.1: |
|||
.zero 2 |
|||
|
|||
.section .data.lsretain2,"aRw" |
|||
.type lsretain2.0, %object |
|||
lsretain2.0: |
|||
.word 1 |
|||
|
|||
.section .text._start,"ax" |
|||
.global _start |
|||
.type _start, %function |
|||
_start: |
|||
.word 0 |
|||
@ -0,0 +1,22 @@ |
|||
.section .preinit_array.01000,"aw",%preinit_array |
|||
.dc.a 0 |
|||
|
|||
.section .init_array.01000,"aw",%init_array |
|||
.dc.a 0 |
|||
|
|||
.section .fini_array.01000,"aw",%fini_array |
|||
.dc.a 0 |
|||
|
|||
.section .preinit_array.01000,"awR",%preinit_array |
|||
.dc.a 0 |
|||
|
|||
.section .init_array.01000,"awR",%init_array |
|||
.dc.a 0 |
|||
|
|||
.section .fini_array.01000,"awR",%fini_array |
|||
.dc.a 0 |
|||
|
|||
.text |
|||
.globl _start |
|||
_start: |
|||
.dc.a 0 |
|||
Loading…
Reference in new issue