aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@gmail.com>2016-12-16 19:17:38 -0800
committerCary Coutant <ccoutant@gmail.com>2016-12-22 20:07:23 -0800
commit7a0c0a1475bf41913c7f25a9e363df26c8f772a1 (patch)
tree8bfd9c4d7c3e1063ac2784f51baf1e51f2331c03 /gold/testsuite
parentc4d5a76223f74930add9014f2a77339eb80b737c (diff)
downloadbinutils-7a0c0a1475bf41913c7f25a9e363df26c8f772a1.zip
binutils-7a0c0a1475bf41913c7f25a9e363df26c8f772a1.tar.gz
binutils-7a0c0a1475bf41913c7f25a9e363df26c8f772a1.tar.bz2
Add -z bndplt support (for Intel MPX).
gold/ PR gold/17643 * options.h (-z bndplt): New option. * x86_64.cc (Output_data_plt_x86_64::regular_count): New method. (Output_data_plt_x86_64::address_for_global): Move implementation into virtual method. (Output_data_plt_x86_64::address_for_local): Likewise. (Output_data_plt_x86_64::got): New method. (Output_data_plt_x86_64::got_plt): New method. (Output_data_plt_x86_64::got_irelative): New method. (Output_data_plt_x86_64::do_address_for_global): New virtual method. (Output_data_plt_x86_64::do_address_for_local): New virtual method. (class Output_data_plt_x86_64_bnd): New class. (Target_x86_64::do_make_data_plt): Move out of line and specialize for each size (both overloads). (Output_data_plt_x86_64::set_final_data_size): Cosmetic changes. * testsuite/Makefile.am (bnd_plt_1): New test case. (bnd_ifunc_1): New test case. (bnd_ifunc_2): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/bnd_ifunc_1.s: New source file. * testsuite/bnd_ifunc_1.sh: New shell script. * testsuite/bnd_ifunc_2.s: New source file. * testsuite/bnd_ifunc_2.sh: New shell script. * testsuite/bnd_plt_1.s: New source file. * testsuite/bnd_plt_1.sh: New shell script.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am29
-rw-r--r--gold/testsuite/Makefile.in42
-rw-r--r--gold/testsuite/bnd_ifunc_1.s16
-rwxr-xr-xgold/testsuite/bnd_ifunc_1.sh36
-rw-r--r--gold/testsuite/bnd_ifunc_2.s28
-rwxr-xr-xgold/testsuite/bnd_ifunc_2.sh50
-rw-r--r--gold/testsuite/bnd_plt_1.s9
-rwxr-xr-xgold/testsuite/bnd_plt_1.sh52
8 files changed, 256 insertions, 6 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 46135a3..6a882ea 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -3046,7 +3046,7 @@ if DEFAULT_TARGET_X86_64
check_PROGRAMS += exception_x86_64_bnd_test
exception_x86_64_bnd_test_SOURCES = exception_test_main.cc
exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
-exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS)
+exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) -Wl,-z,bndplt
exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
exception_x86_64_bnd_1.o: exception_test_1.cc gcctestdir/as
$(CXXCOMPILE) -c -fpic -Bgcctestdir/ -Wa,-madd-bnd-prefix -o $@ $<
@@ -3146,6 +3146,33 @@ split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
MOSTLYCLEANFILES += split_x86_64_1 split_x86_64_2 split_x86_64_3 \
split_x86_64_4 split_x86_64_r
+check_SCRIPTS += bnd_plt_1.sh
+check_DATA += bnd_plt_1.stdout
+bnd_plt_1.o: bnd_plt_1.s
+ $(TEST_AS) --64 -o $@ $<
+bnd_plt_1.so: bnd_plt_1.o ../ld-new
+ ../ld-new -shared -z bndplt bnd_plt_1.o -o $@
+bnd_plt_1.stdout: bnd_plt_1.so
+ $(TEST_OBJDUMP) -dw $< > $@
+
+check_SCRIPTS += bnd_ifunc_1.sh
+check_DATA += bnd_ifunc_1.stdout
+bnd_ifunc_1.o: bnd_ifunc_1.s
+ $(TEST_AS) --64 -madd-bnd-prefix -o $@ $<
+bnd_ifunc_1.so: bnd_ifunc_1.o ../ld-new
+ ../ld-new -shared -z bndplt bnd_ifunc_1.o -o $@
+bnd_ifunc_1.stdout: bnd_ifunc_1.so
+ $(TEST_OBJDUMP) -dw $< > $@
+
+check_SCRIPTS += bnd_ifunc_2.sh
+check_DATA += bnd_ifunc_2.stdout
+bnd_ifunc_2.o: bnd_ifunc_2.s
+ $(TEST_AS) --64 -madd-bnd-prefix -o $@ $<
+bnd_ifunc_2.so: bnd_ifunc_2.o ../ld-new
+ ../ld-new -shared -z bndplt bnd_ifunc_2.o -o $@
+bnd_ifunc_2.stdout: bnd_ifunc_2.so
+ $(TEST_OBJDUMP) -dw $< > $@
+
endif DEFAULT_TARGET_X86_64
if DEFAULT_TARGET_X32
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index e5e3320..202aa9a 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -813,10 +813,18 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \
@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = split_i386_1 split_i386_2 split_i386_3 \
@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_4 split_i386_r
-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = split_x86_64.sh
-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_x86_64_1.stdout split_x86_64_2.stdout \
-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout
-
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = split_x86_64.sh \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_plt_1.sh \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_1.sh \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_2.sh
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_x86_64_1.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_2.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_3.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_4.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_r.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_plt_1.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_1.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_2.stdout
@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \
@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_4 split_x86_64_r
@@ -3352,7 +3360,7 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ehdr_start_test_5_LDADD =
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_SOURCES = exception_test_main.cc
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
-@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS)
+@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) -Wl,-z,bndplt
@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o
@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200
@@ -5224,6 +5232,12 @@ split_i386.sh.log: split_i386.sh
@p='split_i386.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
split_x86_64.sh.log: split_x86_64.sh
@p='split_x86_64.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+bnd_plt_1.sh.log: bnd_plt_1.sh
+ @p='bnd_plt_1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+bnd_ifunc_1.sh.log: bnd_ifunc_1.sh
+ @p='bnd_ifunc_1.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
+bnd_ifunc_2.sh.log: bnd_ifunc_2.sh
+ @p='bnd_ifunc_2.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
split_x32.sh.log: split_x32.sh
@p='split_x32.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post)
arm_abs_global.sh.log: arm_abs_global.sh
@@ -7318,6 +7332,24 @@ uninstall-am:
@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -d $< > $@
@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_x86_64_r.stdout: split_x86_64_1.o split_x86_64_n.o ../ld-new
@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -r split_x86_64_1.o split_x86_64_n.o -o split_x86_64_r > $@ 2>&1 || exit 0
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_plt_1.o: bnd_plt_1.s
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) --64 -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_plt_1.so: bnd_plt_1.o ../ld-new
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -shared -z bndplt bnd_plt_1.o -o $@
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_plt_1.stdout: bnd_plt_1.so
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -dw $< > $@
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_ifunc_1.o: bnd_ifunc_1.s
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) --64 -madd-bnd-prefix -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_ifunc_1.so: bnd_ifunc_1.o ../ld-new
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -shared -z bndplt bnd_ifunc_1.o -o $@
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_ifunc_1.stdout: bnd_ifunc_1.so
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -dw $< > $@
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_ifunc_2.o: bnd_ifunc_2.s
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) --64 -madd-bnd-prefix -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_ifunc_2.so: bnd_ifunc_2.o ../ld-new
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -shared -z bndplt bnd_ifunc_2.o -o $@
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@bnd_ifunc_2.stdout: bnd_ifunc_2.so
+@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_OBJDUMP) -dw $< > $@
@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_x32_1.o: split_x32_1.s
@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $<
@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@split_x32_2.o: split_x32_2.s
diff --git a/gold/testsuite/bnd_ifunc_1.s b/gold/testsuite/bnd_ifunc_1.s
new file mode 100644
index 0000000..82b64f0
--- /dev/null
+++ b/gold/testsuite/bnd_ifunc_1.s
@@ -0,0 +1,16 @@
+ .type foo, %gnu_indirect_function
+ .global __GI_foo
+ .hidden __GI_foo
+ .set __GI_foo, foo
+ .text
+.globl foo
+ .type foo, @function
+foo:
+ ret
+ .size foo, .-foo
+.globl bar
+ .type bar, @function
+bar:
+ call __GI_foo@PLT
+ ret
+ .size bar, .-bar
diff --git a/gold/testsuite/bnd_ifunc_1.sh b/gold/testsuite/bnd_ifunc_1.sh
new file mode 100755
index 0000000..809b0cd
--- /dev/null
+++ b/gold/testsuite/bnd_ifunc_1.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# bnd_ifunc_1.sh -- test -z bndplt for x86_64
+
+# Copyright (C) 2016 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@gmail.com>.
+
+# 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.
+
+match()
+{
+ if ! egrep "$1" "$2" >/dev/null 2>&1; then
+ echo 1>&2 "could not find '$1' in $2"
+ exit 1
+ fi
+}
+
+match '[0-9a-f]*:.*bnd jmpq \*0x[0-9a-f]*\(%rip\) *# [0-9a-f]* <_GLOBAL_OFFSET_TABLE_\+0x18>' bnd_ifunc_1.stdout
+APLT_ADDR=$(egrep '[0-9a-f]*:.*bnd jmpq \*0x[0-9a-f]*\(%rip\) *# [0-9a-f]* <_GLOBAL_OFFSET_TABLE_\+0x18>' bnd_ifunc_1.stdout |
+ sed -e 's/ *\([0-9a-f]*\):.*/\1/')
+match "bnd callq $APLT_ADDR" bnd_ifunc_1.stdout
diff --git a/gold/testsuite/bnd_ifunc_2.s b/gold/testsuite/bnd_ifunc_2.s
new file mode 100644
index 0000000..86470a2
--- /dev/null
+++ b/gold/testsuite/bnd_ifunc_2.s
@@ -0,0 +1,28 @@
+ .text
+ .globl fct1
+ .type fct1, @gnu_indirect_function
+ .set fct1,resolve1
+ .hidden int_fct1
+ .globl int_fct1
+ .set int_fct1,fct1
+ .type resolve1, @function
+resolve1:
+ call func1@PLT
+ .globl g1
+ .type g1, @function
+g1:
+ jmp int_fct1@PLT
+
+ .globl fct2
+ .type fct2, @gnu_indirect_function
+ .set fct2,resolve2
+ .hidden int_fct2
+ .globl int_fct2
+ .set int_fct2,fct2
+ .type resolve2, @function
+resolve2:
+ call func2@PLT
+ .globl g2
+ .type g2, @function
+g2:
+ jmp int_fct2@PLT
diff --git a/gold/testsuite/bnd_ifunc_2.sh b/gold/testsuite/bnd_ifunc_2.sh
new file mode 100755
index 0000000..9476006
--- /dev/null
+++ b/gold/testsuite/bnd_ifunc_2.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# bnd_ifunc_2.sh -- test -z bndplt for x86_64
+
+# Copyright (C) 2016 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@gmail.com>.
+
+# 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.
+
+match()
+{
+ if ! egrep "$1" "$2" >/dev/null 2>&1; then
+ echo 1>&2 "could not find '$1' in $2"
+ exit 1
+ fi
+}
+
+# Extract just the PLT portion of the disassembly.
+get_plt()
+{
+ sed -n -e '/^Disassembly of section .plt:/,/^Disassembly/p'
+}
+
+# Extract the addresses of the indirect jumps, omitting the PLT0 entry.
+get_aplt_jmpq_addresses()
+{
+ sed -n -e '/_GLOBAL_OFFSET_TABLE_+0x10/d' \
+ -e '/bnd jmpq \*0x[0-9a-f]*(%rip)/p' |
+ sed -e 's/ *\([0-9a-f]*\):.*/\1/'
+}
+
+for APLT_ADDR in $(get_plt < bnd_ifunc_2.stdout | get_aplt_jmpq_addresses)
+do
+ match "bnd (callq|jmpq) $APLT_ADDR" bnd_ifunc_2.stdout
+done
diff --git a/gold/testsuite/bnd_plt_1.s b/gold/testsuite/bnd_plt_1.s
new file mode 100644
index 0000000..bf62981
--- /dev/null
+++ b/gold/testsuite/bnd_plt_1.s
@@ -0,0 +1,9 @@
+ .text
+ .globl _start
+_start:
+bnd jmp foo1@plt
+ call foo2@plt
+ jmp foo3@plt
+ call foo4@plt
+bnd call foo3@plt
+ jmp foo4@plt
diff --git a/gold/testsuite/bnd_plt_1.sh b/gold/testsuite/bnd_plt_1.sh
new file mode 100755
index 0000000..ed8256f
--- /dev/null
+++ b/gold/testsuite/bnd_plt_1.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# bnd_plt_1.sh -- test -z bndplt for x86_64
+
+# Copyright (C) 2016 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@gmail.com>.
+
+# 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.
+
+match()
+{
+ if ! egrep "$1" "$2" >/dev/null 2>&1; then
+ echo 1>&2 "could not find '$1' in $2"
+ exit 1
+ fi
+}
+
+# Extract just the PLT portion of the disassembly.
+get_plt()
+{
+ sed -n -e '/^Disassembly of section .plt:/,/^Disassembly/p'
+}
+
+# Extract the addresses of the indirect jumps, omitting the PLT0 entry.
+get_aplt_jmpq_addresses()
+{
+ sed -n -e '/_GLOBAL_OFFSET_TABLE_+0x10/d' \
+ -e '/bnd jmpq \*0x[0-9a-f]*(%rip)/p' |
+ sed -e 's/ *\([0-9a-f]*\):.*/\1/'
+}
+
+match 'bnd jmpq \*0x[0-9a-f]*\(%rip\) *# [0-9a-f]* <_GLOBAL_OFFSET_TABLE_\+0x10>' bnd_plt_1.stdout
+
+for APLT_ADDR in $(get_plt < bnd_ifunc_2.stdout | get_aplt_jmpq_addresses)
+do
+ match "bnd (callq|jmpq) $APLT_ADDR" bnd_ifunc_2.stdout
+done