1 #!/usr/bin/ksh
   2 #
   3 # This file and its contents are supplied under the terms of the
   4 # Common Development and Distribution License ("CDDL"), version 1.0.
   5 # You may only use this file in accordance with the terms of version
   6 # 1.0 of the CDDL.
   7 #
   8 # A full copy of the text of the CDDL should have accompanied this
   9 # source.  A copy of the CDDL is also available via the Internet at
  10 # http://www.illumos.org/license/CDDL.
  11 #
  12 
  13 #
  14 # Copyright 2018, Richard Lowe.
  15 #
  16 
  17 # Test that a simple use of linker-sets, tat is, automatically generated start
  18 # and end symbols for sections can be generated and used.
  19 
  20 if [[ -z $ELF_TESTS ]]; then
  21     print -u2 "Don't know where the test data is rooted";
  22     exit 1;
  23 fi
  24 
  25 tmpdir=/tmp/test.$$
  26 mkdir $tmpdir
  27 cd $tmpdir
  28 
  29 cleanup() {
  30     cd /
  31     rm -fr $tmpdir
  32 }
  33 
  34 trap 'cleanup' EXIT
  35 
  36 # We expect any alternate linker to be in LD_ALTEXEC for us already
  37 gcc -o simple ${ELF_TESTS}/tests/linker-sets/simple-src.c -Wall -Wextra
  38 if (( $? != 0 )); then
  39     print -u2 "compilation of ${ELF_TESTS}/tests/linker-sets/simple-src.c failed";
  40     exit 1;
  41 fi
  42 
  43 ./simple > simple.$$.out 2>&1
  44 
  45 if (( $? != 0 )); then
  46     print -u2 "execution of ${ELF_TESTS}/tests/linker-sets/simple-src.c failed";
  47     exit 1;
  48 fi
  49 
  50 diff -u ${ELF_TESTS}/tests/linker-sets/simple.out simple.$$.out
  51 if (( $? != 0 )); then
  52     print -u2 "${ELF_TESTS}/tests/linker-sets/simple-src.c output mismatch"
  53     exit 1;
  54 fi