From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id 235803948A6A for ; Sat, 21 Mar 2020 00:08:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 235803948A6A Received: by mail-pl1-x634.google.com with SMTP id a23so3198365plm.1 for ; Fri, 20 Mar 2020 17:08:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=maEs+uvBrWdaG0F4hTWUw5rlhB/JbdJWlxOL3ju9pzs=; b=lPwLP2aRTbN4NYuOPEsuhJshVOsJo3do1FospK5j7CD2OCS8fAoH2anpzXyfs1PjnI dyykYuZRjKYn20Fv0zn/dmr3Pb7CHuHeWMIpjIw5VIssf/bPmQw+ycyucrgzkIkos4ci driLzMynfzH65/zsskiDklhh26S9IoPVAoFuLQq7eSBK/RQVX2Hi5AGkGyJa1E7fI0j1 jMgcKHCluOMU6L+BGLA35XoCX6B8+N42KivE7YzgCE+ec3A3kcfR93ynV906Ax2rEX9C YsmsYJ7ewpXkEfaLeX0QTLwEyMjYBNYTaAJupBcL/GAun3djeDioJWgDBOtgV7DBQt9R wBZw== X-Gm-Message-State: ANhLgQ2sUX2rsn+B4XC8HDTQQ3mevN2GtqWOwvotsVj/wqRVCFNZbVVA KLzaUVebE5zORERdep2kJ0RKGGDO X-Google-Smtp-Source: ADFU+vuLDjYXG7yZqXZxK2K1Nzjm1RGt83OPbqsJ50wbEbWyoEoV42/tXrD77woOdiGS9zjmEYrhmw== X-Received: by 2002:a17:902:8d91:: with SMTP id v17mr10371728plo.53.1584749320119; Fri, 20 Mar 2020 17:08:40 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id e26sm6605896pfj.61.2020.03.20.17.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 17:08:39 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id E559FC0502 for ; Fri, 20 Mar 2020 17:08:33 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH 5/6] ld: Add tests for -z nosectionheader and --strip-sections Date: Fri, 20 Mar 2020 17:08:32 -0700 Message-Id: <20200321000833.1138564-6-hjl.tools@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200321000833.1138564-1-hjl.tools@gmail.com> References: <20200321000833.1138564-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-25.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, UNSUBSCRIBE_BODY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Mar 2020 00:08:45 -0000 Add tests to verify that the linker option, -z nosectionheader and objcopy and strip option, --strip-sections, work correctly as well as linker issues an error when dynamic symbol table from PT_DYNAMIC segment is used. PR ld/25617 * testsuite/ld-elf/no-section-header.exp: New file. * testsuite/ld-elf/pr25617-1-no-sec-hdr.nd: Likewise. * testsuite/ld-elf/pr25617-1-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd: Likewise. * testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a-sec-hdr.rd: Likewise. * testsuite/ld-elf/pr25617-1a.c: Likewise. * testsuite/ld-elf/pr25617-1b.c: Likewise. * testsuite/ld-elf/start-noheader.rd: Likewise. * testsuite/ld-elf/start-shared-noheader-gnu.rd: Likewise. * testsuite/ld-elf/start-shared-noheader-sysv.rd: Likewise. * testsuite/ld-elf/start-shared-noheader.nd: Likewise. --- ld/testsuite/ld-elf/no-section-header.exp | 370 ++++++++++++++++++ ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd | 3 + ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd | 20 + .../ld-elf/pr25617-1-static-no-sec-hdr.rd | 12 + ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd | 3 + ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd | 20 + ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd | 19 + ld/testsuite/ld-elf/pr25617-1a.c | 11 + ld/testsuite/ld-elf/pr25617-1b.c | 15 + ld/testsuite/ld-elf/start-noheader.rd | 11 + .../ld-elf/start-shared-noheader-gnu.rd | 22 ++ .../ld-elf/start-shared-noheader-sysv.rd | 22 ++ ld/testsuite/ld-elf/start-shared-noheader.nd | 5 + 13 files changed, 533 insertions(+) create mode 100644 ld/testsuite/ld-elf/no-section-header.exp create mode 100644 ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd create mode 100644 ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd create mode 100644 ld/testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd create mode 100644 ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd create mode 100644 ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd create mode 100644 ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd create mode 100644 ld/testsuite/ld-elf/pr25617-1a.c create mode 100644 ld/testsuite/ld-elf/pr25617-1b.c create mode 100644 ld/testsuite/ld-elf/start-noheader.rd create mode 100644 ld/testsuite/ld-elf/start-shared-noheader-gnu.rd create mode 100644 ld/testsuite/ld-elf/start-shared-noheader-sysv.rd create mode 100644 ld/testsuite/ld-elf/start-shared-noheader.nd diff --git a/ld/testsuite/ld-elf/no-section-header.exp b/ld/testsuite/ld-elf/no-section-header.exp new file mode 100644 index 0000000000..fe57abdbd7 --- /dev/null +++ b/ld/testsuite/ld-elf/no-section-header.exp @@ -0,0 +1,370 @@ +# Expect script for -z nosectionheader and --strip-sections tests +# Copyright (C) 2020 Free Software Foundation, Inc. +# +# This file is part of the GNU Binutils. +# +# 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. +# +# Written by H.J. Lu (hongjiu.lu@intel.com) +# + +# Make sure that binutils can correctly handle ld output in ELF. + +if { ![istarget *-*-linux*] } { + return +} + +proc binutils_test { prog_name ld_options test readelf_expected nm_expected} { + global as + global ld + global READELF + global NM + global objcopy + global strip + global srcdir + global subdir + global link_output + + eval set prog \$$prog_name + + set test_name "$prog_name --strip-sections $ld_options ($test)" + + if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } { + unresolved "$test_name" + return + } + + append ld_options " -z separate-code -z stack-size=0" + if { ![ld_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } { + if { [string match "*not supported*" $link_output] + || [string match "*unrecognized option*" $link_output] + || [string match "*-z .* ignored*" $link_output] } { + unsupported "$ld_options is not supported by this target" + } else { + unresolved "$test_name" + } + return + } + + send_log "$prog --strip-sections tmpdir/$test\n" + set got [remote_exec host "$prog --strip-sections tmpdir/$test"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + fail "$test_name" + return + } + + send_log "$READELF -lSDs --wide tmpdir/$test > tmpdir/$test.out\n" + set got [remote_exec host "$READELF -lSDs --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + unresolved "$test_name" + return + } + + if { [regexp_diff "tmpdir/$test.out" "$srcdir/$subdir/$readelf_expected"] } then { + fail "$test_name" + return + } + + if { [string match "*-shared *" $ld_options] } { + send_log "$NM -D tmpdir/$test > tmpdir/$test.out\n" + set got [remote_exec host "$NM -D tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + unresolved "$test_name" + return + } + + if { [regexp_diff "tmpdir/$test.out" "$srcdir/$subdir/$nm_expected"] } then { + fail "$test_name" + return + } + } + + pass "$test_name" +} + +if { [istarget "mips*-*-*"] } { + set gnu_hash_style "sysv" +} else { + set gnu_hash_style "gnu" +} + +binutils_test objcopy "--hash-style=both" start start-noheader.rd \ + start-noheader.nd +binutils_test objcopy "--hash-style=gnu" start start-noheader.rd \ + start-noheader.nd +binutils_test objcopy "--hash-style=sysv" start start-noheader.rd \ + start-noheader.nd +binutils_test objcopy "--hash-style=both -shared" start \ + start-shared-noheader-$gnu_hash_style.rd start-shared-noheader.nd +binutils_test objcopy "--hash-style=gnu -shared" start \ + start-shared-noheader-$gnu_hash_style.rd start-shared-noheader.nd +binutils_test objcopy "--hash-style=sysv -shared" start \ + start-shared-noheader-sysv.rd start-shared-noheader.nd +binutils_test strip "--hash-style=both" start start-noheader.rd \ + start-noheader.nd +binutils_test strip "--hash-style=gnu" start start-noheader.rd \ + start-noheader.nd +binutils_test strip "--hash-style=sysv" start start-noheader.rd \ + start-noheader.nd +binutils_test strip "--hash-style=both -shared" start \ + start-shared-noheader-$gnu_hash_style.rd start-shared-noheader.nd +binutils_test strip "--hash-style=gnu -shared" start \ + start-shared-noheader-$gnu_hash_style.rd start-shared-noheader.nd +binutils_test strip "--hash-style=sysv -shared" start \ + start-shared-noheader-sysv.rd start-shared-noheader.nd + +# Skip non-native targets or -shared is not supported. +if { ![isnative] || ![check_shared_lib_support] } { + return +} + +proc binutils_run_test { prog } { + global CC + global gcc_B_opt + global READELF + global NM + global objcopy + global strip + global srcdir + global subdir + # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required. + global NOPIE_CFLAGS NOPIE_LDFLAGS + + set sec_hdr "sec-hdr" + if { "$prog" == "" } { + set prog_name none + } else { + set prog_name $prog + set ld_options "" + switch -- $prog { + objcopy + { set prog $objcopy } + strip + { set prog $strip } + default + { + fail "Build pr25617-1a-no-sec-hdr.so ($prog_name)" + break + } + } + } + + run_cc_link_tests [list \ + [list \ + "Build pr25617-1a-no-sec-hdr.so ($prog_name)" \ + "-shared -Wl,-z,separate-code,--hash-style=sysv" \ + "-fPIC" \ + {pr25617-1a.c} \ + [list \ + [list "readelf" "-lWSDs" "pr25617-1a-$sec_hdr.rd"] \ + [list "nm" "-Ds" "pr25617-1a-no-sec-hdr.nd"] \ + ]\ + "pr25617-1a-no-sec-hdr.so" \ + ] \ + [list \ + "Build pr25617-1a-now-no-sec-hdr.so ($prog_name)" \ + "-shared -Wl,-z,separate-code,-z,now,--hash-style=gnu" \ + "-fPIC" \ + {pr25617-1a.c} \ + [list \ + [list "readelf" "-lWSDs" "pr25617-1a-$sec_hdr.rd"] \ + [list "nm" "-Ds" "pr25617-1a-no-sec-hdr.nd"] \ + ]\ + "pr25617-1a-now-no-sec-hdr.so" \ + ] \ + [list \ + "Build pr25617-1 (-z nosectionheader, $prog_name)" \ + "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed \ + -Wl,--hash-style=sysv -Wl,-z,nosectionheader \ + tmpdir/pr25617-1a-no-sec-hdr.so" \ + "$NOPIE_CFLAGS" \ + {pr25617-1b.c} \ + {{readelf -lWSDs pr25617-1-no-sec-hdr.rd} \ + {nm -Ds pr25617-1-no-sec-hdr.nd}} \ + "pr25617-1-no-sec-hdr" \ + ] \ + [list \ + "Build pr25617-1 (PIE, -z nosectionheader, $prog_name)" \ + "-pie -Wl,-z,separate-code,--no-as-needed,--hash-style=gnu \ + -Wl,-z,nosectionheader tmpdir/pr25617-1a-now-no-sec-hdr.so" \ + "-fPIE" \ + {pr25617-1b.c} \ + {{readelf -lWSDs pr25617-1-no-sec-hdr.rd} \ + {nm -Ds pr25617-1-no-sec-hdr.nd}} \ + "pr25617-1-pie-no-sec-hdr" \ + ] \ + [list \ + "Build pr25617-1 (static, -z nosectionheader, $prog_name)" \ + "-static -Wl,-z,separate-code -Wl,-z,nosectionheader" \ + "" \ + {pr25617-1a.c pr25617-1b.c} \ + {{readelf -lSWDs pr25617-1-static-no-sec-hdr.rd}} \ + "pr25617-1-static-no-sec-hdr" \ + ] \ + ] + + run_ld_link_exec_tests [list \ + [list \ + "Run pr25617-1 (-z nosectionheader, $prog_name)" \ + "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed \ + -Wl,--hash-style=sysv -Wl,-z,nosectionheader \ + tmpdir/pr25617-1a-no-sec-hdr.so" \ + "" \ + {pr25617-1b.c} \ + "pr25617-1-no-sec-hdr" \ + "pass.out" \ + "$NOPIE_CFLAGS" \ + ] \ + [list \ + "Run pr25617-1 (PIE, -z nosectionheader, $prog_name)" \ + "-pie -Wl,-z,separate-code,--no-as-needed,--hash-style=gnu \ + -Wl,-z,nosectionheader tmpdir/pr25617-1a-now-no-sec-hdr.so" \ + "" \ + {pr25617-1b.c} \ + "pr25617-1-pie-no-sec-hdr" \ + "pass.out" \ + "-fPIE" \ + ] \ + [list \ + "Run pr25617-1 (static, -z nosectionheader, $prog_name)" \ + "-static -Wl,-z,separate-code -Wl,-z,nosectionheader" \ + "" \ + {pr25617-1a.c pr25617-1b.c} \ + "pr25617-1-static-no-sec-hdr" \ + "pass.out" \ + ] \ + ] + + if { "$prog_name" != "none" } { + send_log "$prog --strip-sections tmpdir/pr25617-1a-no-sec-hdr.so\n" + set got [remote_exec host "$prog --strip-sections tmpdir/pr25617-1a-no-sec-hdr.so"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + fail "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + send_log "$READELF -lWSDs tmpdir/pr25617-1a-no-sec-hdr.so > tmpdir/dump.out\n" + set got [remote_exec host "$READELF -lWSDs tmpdir/pr25617-1a-no-sec-hdr.so" "" "/dev/null" "tmpdir/dump.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/pr25617-1a-no-sec-hdr.rd"] } then { + unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + send_log "$NM -Ds tmpdir/pr25617-1a-no-sec-hdr.so > tmpdir/dump.out\n" + set got [remote_exec host "$NM -Ds tmpdir/pr25617-1a-no-sec-hdr.so" "" "/dev/null" "tmpdir/dump.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/pr25617-1a-no-sec-hdr.nd"] } then { + unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + send_log "tmpdir/pr25617-1-no-sec-hdr > tmpdir/pr25617-1.out\n" + catch "exec tmpdir/pr25617-1-no-sec-hdr > tmpdir/pr25617-1.out" got + if ![string match "" $got] then { + send_log "$got\n" + unresolved "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + send_log "diff tmpdir/pr25617-1.out $srcdir/$subdir/pass.out\n" + catch "exec diff tmpdir/pr25617-1.out $srcdir/$subdir/pass.out" got + if ![string match "" $got] then { + send_log "$got\n" + fail "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + return + } + + pass "Update pr25617-1a-no-sec-hdr.so ($prog_name)" + + send_log "$prog --strip-sections tmpdir/pr25617-1a-now-no-sec-hdr.so\n" + set got [remote_exec host "$prog --strip-sections tmpdir/pr25617-1a-now-no-sec-hdr.so"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + fail "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + send_log "$READELF -lWSDs tmpdir/pr25617-1a-now-no-sec-hdr.so > tmpdir/dump.out\n" + set got [remote_exec host "$READELF -lWSDs tmpdir/pr25617-1a-now-no-sec-hdr.so" "" "/dev/null" "tmpdir/dump.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/pr25617-1a-no-sec-hdr.rd"] } then { + unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + send_log "$NM -Ds tmpdir/pr25617-1a-now-no-sec-hdr.so > tmpdir/dump.out\n" + set got [remote_exec host "$NM -Ds tmpdir/pr25617-1a-now-no-sec-hdr.so" "" "/dev/null" "tmpdir/dump.out"] + if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then { + send_log "$got\n" + unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + if { [regexp_diff "tmpdir/dump.out" "$srcdir/$subdir/pr25617-1a-no-sec-hdr.nd"] } then { + unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + send_log "tmpdir/pr25617-1-pie-no-sec-hdr > tmpdir/pr25617-1-pie.out\n" + catch "exec tmpdir/pr25617-1-pie-no-sec-hdr > tmpdir/pr25617-1-pie.out" got + if ![string match "" $got] then { + send_log "$got\n" + unresolved "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + send_log "diff tmpdir/pr25617-1-pie.out $srcdir/$subdir/pass.out\n" + catch "exec diff tmpdir/pr25617-1-pie.out $srcdir/$subdir/pass.out" got + if ![string match "" $got] then { + send_log "$got\n" + fail "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + return + } + + send_log "$CC $gcc_B_opt -o tmpdir/pr25617-1 tmpdir/pr25617-1b.o tmpdir/pr25617-1a-now-no-sec-hdr.so\n" + catch "exec $CC $gcc_B_opt -o tmpdir/pr25617-1 tmpdir/pr25617-1b.o tmpdir/pr25617-1a-now-no-sec-hdr.so" got + if ![string match "*pr25617-1a-now-no-sec-hdr.so*file in wrong format*" $got] then { + send_log "$got\n" + fail "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + } + + pass "Update pr25617-1a-now-no-sec-hdr.so ($prog_name)" + } +} + +binutils_run_test "" +binutils_run_test objcopy +binutils_run_test strip diff --git a/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd b/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd new file mode 100644 index 0000000000..6a96f5b55a --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.nd @@ -0,0 +1,3 @@ +#... +[a-f0-9 ]+ [DU] _?protected + + U _?test diff --git a/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd new file mode 100644 index 0000000000..be49dea32d --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1-no-sec-hdr.rd @@ -0,0 +1,20 @@ +#readelf: -lWSDs + +There are no sections in this file. + +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#... + DYNAMIC .* +#... + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +FUNC +GLOBAL +DEFAULT +UND +__libc_start_main(@.*|) +#... + +[0-9]+: +[a-f0-9]+ +0+ +FUNC +GLOBAL +DEFAULT +UND +_?test +#pass diff --git a/ld/testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd new file mode 100644 index 0000000000..92b1dc9ead --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1-static-no-sec-hdr.rd @@ -0,0 +1,12 @@ +#readelf: -lWSDs + +There are no sections in this file. + +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#... +Dynamic symbol information is not available for displaying symbols\. diff --git a/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd new file mode 100644 index 0000000000..86fcc624af --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.nd @@ -0,0 +1,3 @@ +#... + + U _?puts +[0-9a-z]+ T _?test diff --git a/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd new file mode 100644 index 0000000000..f7a4eec736 --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1a-no-sec-hdr.rd @@ -0,0 +1,20 @@ +#readelf: -lWSDs + +There are no sections in this file. + +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#... + DYNAMIC .* +#... + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +FUNC +GLOBAL +DEFAULT +UND +_?puts(@.*|) +#... + +[0-9]+: +[a-f0-9]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +_?test +#pass diff --git a/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd b/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd new file mode 100644 index 0000000000..9ccf0565af --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1a-sec-hdr.rd @@ -0,0 +1,19 @@ +#readelf: -lWSDs + +There are [0-9]+ section headers, starting at offset 0x[a-f0-9]+: +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#... + DYNAMIC .* +#... + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +FUNC +GLOBAL +DEFAULT +UND +_?puts(@.*|) +#... + +[0-9]+: +[a-f0-9]+ +[0-9]+ +FUNC +GLOBAL +DEFAULT +[0-9]+ +_?test +#pass diff --git a/ld/testsuite/ld-elf/pr25617-1a.c b/ld/testsuite/ld-elf/pr25617-1a.c new file mode 100644 index 0000000000..e8fdfde5f6 --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1a.c @@ -0,0 +1,11 @@ +#include + +int protected __attribute__ ((visibility ("protected"))) = 42; +extern int *get_protected_ptr (void); + +void +test() +{ + if (&protected == get_protected_ptr ()) + printf ("PASS\n"); +} diff --git a/ld/testsuite/ld-elf/pr25617-1b.c b/ld/testsuite/ld-elf/pr25617-1b.c new file mode 100644 index 0000000000..1fd6ef45d7 --- /dev/null +++ b/ld/testsuite/ld-elf/pr25617-1b.c @@ -0,0 +1,15 @@ +void test(void); + +extern int protected; + +int * +get_protected_ptr (void) +{ + return &protected; +} + +int main() +{ + test(); + return 0; +} diff --git a/ld/testsuite/ld-elf/start-noheader.rd b/ld/testsuite/ld-elf/start-noheader.rd new file mode 100644 index 0000000000..2479e34087 --- /dev/null +++ b/ld/testsuite/ld-elf/start-noheader.rd @@ -0,0 +1,11 @@ +#readelf: -SlDs --wide + +There are no sections in this file. + +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#pass diff --git a/ld/testsuite/ld-elf/start-shared-noheader-gnu.rd b/ld/testsuite/ld-elf/start-shared-noheader-gnu.rd new file mode 100644 index 0000000000..3397a576ba --- /dev/null +++ b/ld/testsuite/ld-elf/start-shared-noheader-gnu.rd @@ -0,0 +1,22 @@ +#readelf: -SlDs --wide + +There are no sections in this file. + +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#... + DYNAMIC .* +#... + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +main + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +start + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_main + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__start +#pass diff --git a/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd b/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd new file mode 100644 index 0000000000..23a87f98bc --- /dev/null +++ b/ld/testsuite/ld-elf/start-shared-noheader-sysv.rd @@ -0,0 +1,22 @@ +#readelf: -SlDs --wide + +There are no sections in this file. + +#... +Program Headers: + Type +Offset +VirtAddr.* +# On MIPS, the first segment is for .reginfo. +#... + LOAD .* +#... + DYNAMIC .* +#... + +Num: +Value +Size Type +Bind +Vis +Ndx Name + +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND + +#... + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +__start + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_start + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +main + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +start + +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +[0-9]+ +_main +#pass diff --git a/ld/testsuite/ld-elf/start-shared-noheader.nd b/ld/testsuite/ld-elf/start-shared-noheader.nd new file mode 100644 index 0000000000..2d3ba70e53 --- /dev/null +++ b/ld/testsuite/ld-elf/start-shared-noheader.nd @@ -0,0 +1,5 @@ +[0-9a-z]+ A __start +[0-9a-z]+ A _main +[0-9a-z]+ A _start +[0-9a-z]+ A main +[0-9a-z]+ A start -- 2.25.1