Blame tests/run-readelf-n.sh

Packit 032894
# Copyright (C) 2018 Red Hat, Inc.
Packit 032894
# This file is part of elfutils.
Packit 032894
#
Packit 032894
# This file is free software; you can redistribute it and/or modify
Packit 032894
# it under the terms of the GNU General Public License as published by
Packit 032894
# the Free Software Foundation; either version 3 of the License, or
Packit 032894
# (at your option) any later version.
Packit 032894
#
Packit 032894
# elfutils is distributed in the hope that it will be useful, but
Packit 032894
# WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 032894
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 032894
# GNU General Public License for more details.
Packit 032894
#
Packit 032894
# You should have received a copy of the GNU General Public License
Packit 032894
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 032894
Packit 032894
. $srcdir/test-subr.sh
Packit 032894
Packit 032894
# - testfile-gnu-property-note.c
Packit 032894
# int
Packit 032894
# main ()
Packit 032894
# {
Packit 032894
#   return 0;
Packit 032894
# }
Packit 032894
#
Packit 032894
# gcc -fcf-protection -c testfile-gnu-property-note.c
Packit 032894
# gcc -o testfile-gnu-property-note testfile-gnu-property-note.o
Packit 032894
# eu-strip --strip-sections testfile-gnu-property-note
Packit 032894
Packit 032894
testfiles testfile-gnu-property-note.o testfile-gnu-property-note
Packit 032894
Packit 032894
# Test reading notes through sections
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile-gnu-property-note.o << EOF
Packit 032894
Packit 032894
Note section [ 6] '.note.gnu.property' of 32 bytes at offset 0x80:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   16  GNU_PROPERTY_TYPE_0
Packit 032894
    X86 FEATURE_1_AND: 00000003 IBT SHSTK
Packit 032894
EOF
Packit 032894
Packit 032894
# Test reading notes through segments
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile-gnu-property-note << EOF
Packit 032894
Packit 032894
Note segment of 32 bytes at offset 0x300:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   16  GNU_PROPERTY_TYPE_0
Packit 032894
    X86 FEATURE_1_AND: 00000003 IBT SHSTK
Packit 032894
Packit 032894
Note segment of 68 bytes at offset 0x320:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   16  GNU_ABI_TAG
Packit 032894
    OS: Linux, ABI: 3.2.0
Packit 032894
  GNU                   20  GNU_BUILD_ID
Packit 032894
    Build ID: 83cb2229fabd2065d1361f5b46424cd75270f94b
Packit 032894
EOF
Packit 032894
Packit 032894
# NT_VERSION note type clashes with "GNU" owner type NT_GNU_ABI_TAG.
Packit 032894
# Uses owner name (with zero desc) for version string.
Packit 032894
testfiles testfile11
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile11 << EOF
Packit 032894
Packit 032894
Note section [ 2] '.note.ABI-tag' of 32 bytes at offset 0x128:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   16  GNU_ABI_TAG
Packit 032894
    OS: Linux, ABI: 2.2.5
Packit 032894
Packit 032894
Note section [35] '.note' of 60 bytes at offset 0x13364:
Packit 032894
  Owner          Data size  Type
Packit 032894
  01.01                  0  VERSION
Packit 032894
  01.01                  0  VERSION
Packit 032894
  01.01                  0  VERSION
Packit 032894
EOF
Packit 032894
Packit 032894
# See run-annobingroup.sh
Packit 032894
testfiles testfile-annobingroup.o
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile-annobingroup.o << EOF
Packit 032894
Packit 032894
Note section [ 5] '.gnu.build.attributes' of 272 bytes at offset 0x50:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GA                    16  GNU Build Attribute OPEN
Packit 032894
    Address Range: 0 - 0
Packit 032894
    VERSION: "3p8"
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    TOOL: "gcc 8.1.1 20180712"
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    "GOW": 5
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    STACK_PROT: 0
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    "stack_clash": FALSE
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    "cf_protection": 0
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    PIC: 0
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    SHORT_ENUM: FALSE
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    ABI: c001100000012
Packit 032894
  GA                     0  GNU Build Attribute OPEN
Packit 032894
    "stack_realign": FALSE
Packit 032894
Packit 032894
Note section [ 7] '.gnu.build.attributes..text.unlikely' of 216 bytes at offset 0x160:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GA                    16  GNU Build Attribute FUNC
Packit 032894
    Address Range: 0 - 0
Packit 032894
    ABI: c001100000012
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    "stack_realign": FALSE
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    STACK_PROT: 0
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    "stack_clash": FALSE
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    "cf_protection": 0
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    PIC: 0
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    "GOW": 5
Packit 032894
  GA                     0  GNU Build Attribute FUNC
Packit 032894
    SHORT_ENUM: FALSE
Packit 032894
Packit 032894
Note section [22] '.note.gnu.property' of 48 bytes at offset 0x40c:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   32  GNU_PROPERTY_TYPE_0
Packit 032894
    X86 0xc0000000 data: 00 00 00 00
Packit 032894
    X86 0xc0000001 data: 00 00 00 00
Packit 032894
EOF
Packit 032894
Packit 032894
#
Packit 032894
# = gnu_props.S
Packit 032894
#
Packit 032894
# #define NT_GNU_PROPERTY_TYPE_0 5
Packit 032894
# #define GNU_PROPERTY_STACK_SIZE 1
Packit 032894
# #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
Packit 032894
Packit 032894
# /* Normal notes always have alignment and padding of 4 bytes,
Packit 032894
#    but GNU Property notes use 4 byte words, with 8 byte padding
Packit 032894
#    for ELFCLASS64.  */
Packit 032894
# #if __SIZEOF_PTRDIFF_T__  == 8
Packit 032894
# # define ALIGN 3
Packit 032894
# #elif __SIZEOF_PTRDIFF_T__  == 4
Packit 032894
# # define ALIGN 2
Packit 032894
# #endif
Packit 032894
#
Packit 032894
# 	.section ".note.gnu.property", "a"
Packit 032894
# 	.p2align ALIGN
Packit 032894
# 	/* First note.  */
Packit 032894
# 	.long 1f - 0f			/* name length.  */
Packit 032894
# 	.long 4f - 2f			/* data length.  */
Packit 032894
# 	.long NT_GNU_PROPERTY_TYPE_0	/* note type.  */
Packit 032894
# 0:
Packit 032894
# 	.asciz "GNU"			/* vendor name.  */
Packit 032894
# 1:
Packit 032894
# 	.p2align ALIGN			/* Padding.  */
Packit 032894
# 2:
Packit 032894
# 	.long GNU_PROPERTY_STACK_SIZE	/* pr_type.  */
Packit 032894
# 	.long 4f - 3f			/* pr_datasz.  */
Packit 032894
# 3:
Packit 032894
# 	.dc.a 0x280000			/* Stack size.  */
Packit 032894
# 4:
Packit 032894
# 	.p2align ALIGN
Packit 032894
#
Packit 032894
# 	/* Second note.  */
Packit 032894
# 	.long 6f - 5f				/* name length.  */
Packit 032894
# 	.long 8f - 7f				/* data length.  */
Packit 032894
# 	.long NT_GNU_PROPERTY_TYPE_0		/* note type.  */
Packit 032894
# 5:
Packit 032894
# 	.asciz "GNU"				/* vendor name.  */
Packit 032894
# 6:
Packit 032894
# 	.p2align ALIGN				/* Padding.  */
Packit 032894
# 7:
Packit 032894
# 	.long GNU_PROPERTY_NO_COPY_ON_PROTECTED /* pr_type.  */
Packit 032894
# 	.long 0					/* pr_datasz.  */
Packit 032894
# 	/* No data.  */
Packit 032894
# 8:
Packit 032894
# 	.p2align ALIGN
Packit 032894
#
Packit 032894
# On x86_64
Packit 032894
# gcc -m64 -c -o testfile_gnu_props_64le.o gnu_props.S
Packit 032894
# gcc -m32 -c -o testfile_gnu_props_32le.o gnu_props.S
Packit 032894
Packit 032894
testfiles testfile_gnu_props.32le.o testfile_gnu_props.64le.o
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.32le.o << EOF
Packit 032894
Packit 032894
Note section [ 4] '.note.gnu.property' of 52 bytes at offset 0x34:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   12  GNU_PROPERTY_TYPE_0
Packit 032894
    STACK_SIZE 0x280000
Packit 032894
  GNU                    8  GNU_PROPERTY_TYPE_0
Packit 032894
    NO_COPY_ON_PROTECTION
Packit 032894
EOF
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.64le.o << EOF
Packit 032894
Packit 032894
Note section [ 4] '.note.gnu.property' of 56 bytes at offset 0x40:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   16  GNU_PROPERTY_TYPE_0
Packit 032894
    STACK_SIZE 0x280000
Packit 032894
  GNU                    8  GNU_PROPERTY_TYPE_0
Packit 032894
    NO_COPY_ON_PROTECTION
Packit 032894
EOF
Packit 032894
Packit 032894
# On ppc64
Packit 032894
# gcc -m32 -c -o testfile_gnu_props.32be.o gnu_props.S
Packit 032894
# gcc -m64 -c -o testfile_gnu_props.64be.o gnu_props.S
Packit 032894
Packit 032894
testfiles testfile_gnu_props.32be.o testfile_gnu_props.64be.o
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.32be.o << EOF
Packit 032894
Packit 032894
Note section [ 4] '.note.gnu.property' of 52 bytes at offset 0x34:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   12  GNU_PROPERTY_TYPE_0
Packit 032894
    STACK_SIZE 0x280000
Packit 032894
  GNU                    8  GNU_PROPERTY_TYPE_0
Packit 032894
    NO_COPY_ON_PROTECTION
Packit 032894
EOF
Packit 032894
Packit 032894
testrun_compare ${abs_top_builddir}/src/readelf -n testfile_gnu_props.64be.o << EOF
Packit 032894
Packit 032894
Note section [ 4] '.note.gnu.property' of 56 bytes at offset 0x40:
Packit 032894
  Owner          Data size  Type
Packit 032894
  GNU                   16  GNU_PROPERTY_TYPE_0
Packit 032894
    STACK_SIZE 0x280000
Packit 032894
  GNU                    8  GNU_PROPERTY_TYPE_0
Packit 032894
    NO_COPY_ON_PROTECTION
Packit 032894
EOF