1*b6a0e2cdSRichard Lowe#!/usr/bin/ksh 2*b6a0e2cdSRichard Lowe# 3*b6a0e2cdSRichard Lowe# This file and its contents are supplied under the terms of the 4*b6a0e2cdSRichard Lowe# Common Development and Distribution License ("CDDL"), version 1.0. 5*b6a0e2cdSRichard Lowe# You may only use this file in accordance with the terms of version 6*b6a0e2cdSRichard Lowe# 1.0 of the CDDL. 7*b6a0e2cdSRichard Lowe# 8*b6a0e2cdSRichard Lowe# A full copy of the text of the CDDL should have accompanied this 9*b6a0e2cdSRichard Lowe# source. A copy of the CDDL is also available via the Internet at 10*b6a0e2cdSRichard Lowe# http://www.illumos.org/license/CDDL. 11*b6a0e2cdSRichard Lowe# 12*b6a0e2cdSRichard Lowe 13*b6a0e2cdSRichard Lowe# 14*b6a0e2cdSRichard Lowe# Copyright 2018, Richard Lowe. 15*b6a0e2cdSRichard Lowe# 16*b6a0e2cdSRichard Lowe 17*b6a0e2cdSRichard Lowe# Test that existing definitions of the start/stop symbols are reported 18*b6a0e2cdSRichard Lowe# as conflicting with internal symbols. 19*b6a0e2cdSRichard Lowe 20*b6a0e2cdSRichard Lowetmpdir=/tmp/test.$$ 21*b6a0e2cdSRichard Lowemkdir $tmpdir 22*b6a0e2cdSRichard Lowecd $tmpdir 23*b6a0e2cdSRichard Lowe 24*b6a0e2cdSRichard Lowecleanup() { 25*b6a0e2cdSRichard Lowe cd / 26*b6a0e2cdSRichard Lowe rm -fr $tmpdir 27*b6a0e2cdSRichard Lowe} 28*b6a0e2cdSRichard Lowe 29*b6a0e2cdSRichard Lowetrap 'cleanup' EXIT 30*b6a0e2cdSRichard Lowe 31*b6a0e2cdSRichard Lowecat > broken.c <<EOF 32*b6a0e2cdSRichard Lowechar foo[1024] __attribute__((section("set_foo"))); 33*b6a0e2cdSRichard Lowevoid *__start_set_foo; 34*b6a0e2cdSRichard Lowe 35*b6a0e2cdSRichard Loweint 36*b6a0e2cdSRichard Lowemain() 37*b6a0e2cdSRichard Lowe{ 38*b6a0e2cdSRichard Lowe return (0); 39*b6a0e2cdSRichard Lowe} 40*b6a0e2cdSRichard LoweEOF 41*b6a0e2cdSRichard Lowe 42*b6a0e2cdSRichard Lowe# We expect any alternate linker to be in LD_ALTEXEC for us already 43*b6a0e2cdSRichard Lowegcc -o broken broken.c -Wall -Wextra -Wl,-zfatal-warnings > in-use.$$.out 2>&1 44*b6a0e2cdSRichard Loweif (( $? == 0 )); then 45*b6a0e2cdSRichard Lowe print -u2 "use of a reserved symbol didn't fail" 46*b6a0e2cdSRichard Lowe exit 1; 47*b6a0e2cdSRichard Lowefi 48*b6a0e2cdSRichard Lowe 49*b6a0e2cdSRichard Lowegrep -q "^ld: warning: reserved symbol '__start_set_foo' already defined in file" in-use.$$.out 50*b6a0e2cdSRichard Loweif (( $? != 0 )); then 51*b6a0e2cdSRichard Lowe print -u2 "use of a reserved symbol failed for the wrong reason" 52*b6a0e2cdSRichard Lowe exit 1; 53*b6a0e2cdSRichard Lowefi 54