From: Nick Clifton Date: Mon, 30 Apr 2018 08:58:30 +0000 (+0100) Subject: check-abi: With --verbose, show all the notes extracted. X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=cd0f37ad39b1ee5ec07b286106234bb13d334eec;p=annobin.git check-abi: With --verbose, show all the notes extracted. abi-test: Skip the ABI check, since the crt[in].o files are compiled with different settings. --- diff --git a/doc/annotation.proposal.txt b/doc/annotation.proposal.txt index 9dee4e8..1fe0d0b 100644 --- a/doc/annotation.proposal.txt +++ b/doc/annotation.proposal.txt @@ -141,10 +141,10 @@ Some examples: supported by the notes. The next pair of characters indicate who produced the notes and which version of this producer has been used. A 'p' character indicates a compiler plugin. An 'l' - character indicates the linker. Other characters may be defined in - the future. Multiple producers can contribute to the notes. Their - identifying pair of characters should be appended to the version - note. + character indicates the linker. An 'a' character indicates the + assembler. Other characters may be defined in the future. Multiple + producers can contribute to the notes. Their identifying pair of + characters should be appended to the version note. The description field for the version note should not be empty. This note serves as the base address for other open notes that diff --git a/scripts/check-abi.sh b/scripts/check-abi.sh index c8550c0..09498f8 100755 --- a/scripts/check-abi.sh +++ b/scripts/check-abi.sh @@ -368,7 +368,9 @@ scan_file () return fi fi - + + verbose "NOTES: `cat $tmpfile`" + if [ $ignore_gaps -eq 0 ]; then grep -q -e "Gap in build notes" $tmpfile diff --git a/tests/Makefile.am b/tests/Makefile.am index 081d49b..9c945d0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,7 +6,14 @@ ## Process this file with automake to produce Makefile.in. -TESTS=compile-test hardening-test hardening-fail-test abi-test missing-notes-test function-sections-test +TESTS=compile-test \ + hardening-test \ + hardening-fail-test \ + abi-test \ + missing-notes-test \ + function-sections-test \ + assembler-gap-test + XFAIL_TESTS=hardening-fail-test # FIXME: Add a test for merging notes... diff --git a/tests/Makefile.in b/tests/Makefile.in index 2c9e007..6745fa2 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -211,7 +211,14 @@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -TESTS = compile-test hardening-test hardening-fail-test abi-test missing-notes-test function-sections-test +TESTS = compile-test \ + hardening-test \ + hardening-fail-test \ + abi-test \ + missing-notes-test \ + function-sections-test \ + assembler-gap-test + XFAIL_TESTS = hardening-fail-test all: all-am diff --git a/tests/abi-test b/tests/abi-test index dc701f8..2f6998b 100755 --- a/tests/abi-test +++ b/tests/abi-test @@ -65,13 +65,17 @@ $GCC -fplugin=$PLUGIN \ # $OBJCOPY --merge-notes abi-test.exe abi-test-merged.exe # The --ignore-FORTIFY and --ignore-stack-prot options are here to skip the -# checks that fail because they require a version of readelf that knows how -# to fully parse the annobin notes and such a version is not in common -# release (yet). -# FIXME: Remove these options once readelf has been updated. +# checks that fail because the startup and end files (Scrti.o, crtn.o) are +# built without these safeguards, whereas the test files use them. Similarly +# the --ignore-ABI option is because these two files are compiled with different +# ABI settings from normal code. # # The --ignore-gaps option is there because currently Scrti.o contains some # annobin notes, but crti.o dies not. Thus *any* program built with normal # startup code will contain a gap. -# FIXME: Add assembler support for generating notes. -$srcdir/../scripts/check-abi.sh --readelf=$READELF --inconsistencies --ignore-FORTIFY --ignore-stack-prot --ignore-gaps abi-test.exe +# FIXME: Remove once we have the assembler generating notes. +$srcdir/../scripts/check-abi.sh --readelf=$READELF --inconsistencies \ + --ignore-FORTIFY --ignore-stack-prot \ + --ignore-gaps --ignore-ABI \ + abi-test.exe + diff --git a/tests/assembler-gap-test b/tests/assembler-gap-test new file mode 100755 index 0000000..4b7a9e6 --- /dev/null +++ b/tests/assembler-gap-test @@ -0,0 +1,44 @@ +#!/bin/bash + +# Copyright (c) 2018 Red Hat. +# +# This 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, or (at your +# option) any later version. +# +# It 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. + + +# Test building an assembler source file without creating a gap in the notes. + +rm -f hello.o gap.o hello3.o assembler-gap-test.exe assembler-gas-test.out + +GAS=as +# GAS=/work/builds/binutils/current/x86_64-pc-linux-gnu/gas/as-new +GCC=gcc +READELF=readelf + +PLUGIN=../plugin/.libs/annobin.so + +$GCC -fplugin=$PLUGIN -c $srcdir/hello.c + +$GAS --generate-missing-build-notes=yes $srcdir/gap.S -o gap.o +# $GAS --generate-missing-build-notes=no $srcdir/gap.S -o gap.o + +$GCC -fplugin=$PLUGIN -c $srcdir/hello3.c + +$GCC hello.o gap.o hello3.o -o assembler-gap-test.exe -Wl,--defsym,big_stack=0 + +# FIXME - we should check that the notes were parsed correctly... +$READELF --notes --wide assembler-gap-test.exe > /dev/null 2> assembler-gap-test.out + +# FAIL if there was a gap in the notes... +if [ -s assembler-gap-test.out ]; +then + exit 1 +fi + diff --git a/tests/function-sections-test b/tests/function-sections-test index a6ccb39..0a9d2ce 100755 --- a/tests/function-sections-test +++ b/tests/function-sections-test @@ -16,7 +16,6 @@ rm -f hello.o hello2.o hello3.o libhello.so function-section-test.exe GCC=gcc READELF=readelf -OBJCOPY=objcopy PLUGIN=../plugin/.libs/annobin.so diff --git a/tests/gap.S b/tests/gap.S new file mode 100644 index 0000000..bcb1400 --- /dev/null +++ b/tests/gap.S @@ -0,0 +1,6 @@ + .text + .dc.l 0 + .dc.l 2 + .dc.l 4 + .dc.l 6 + diff --git a/tests/missing-notes-test b/tests/missing-notes-test index 74ecab0..9a36523 100755 --- a/tests/missing-notes-test +++ b/tests/missing-notes-test @@ -12,11 +12,10 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -rm -f hello.o hello2.o hello3.o libhello.so compile-test.exe +rm -f hello.o hello2.o hello3.o libhello.so missing-notes-test.exe GCC=gcc READELF=readelf -OBJCOPY=objcopy PLUGIN=../plugin/.libs/annobin.so