binutils-gdb/ld/emultempl/elf-x86.em
H.J. Lu 74e10d1742 x86: Check static link of dynamic objects
On Linux/x86, when -static is passed to gcc, gcc passes it to linker
before all input files suitable for creating static executable.  X86
linker will report error for dynamic input objects if -static is passed
at command-line before all input files without --dynamic-linker unless
--no-dynamic-linker is used.

bfd/

	PR ld/24920
	* elf-linker-x86.h (elf_linker_x86_params): Add
	static_before_all_inputs and has_dynamic_linker.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Report
	dynamic input objects if -static is passed at command-line
	before all input files without --dynamic-linker unless
	--no-dynamic-linker is used.

ld/

	PR ld/24920
	* emulparams/elf32_x86_64.sh: Use static.sh.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/static.sh: New file.
	* emultempl/elf-x86.em: Include "ldlex.h".
	* testsuite/ld-elf/pr24920.err: New file.
	* testsuite/ld-elf/linux-x86.exp: Run ld/24920 tests.
2020-03-13 07:39:06 -07:00

59 lines
1.5 KiB
Plaintext

# This shell script emits a C file. -*- C -*-
# Copyright (C) 2019-2020 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
# 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; see the file COPYING3. If not,
# see <http://www.gnu.org/licenses/>.
#
# This file is sourced from elf.em, and defines x86 specific routines.
#
fragment <<EOF
#include "ldlex.h"
#include "elf-linker-x86.h"
static struct elf_linker_x86_params params;
/* This is a convenient point to tell BFD about target specific flags.
After the output has been created, but before inputs are read. */
static void
elf_x86_create_output_section_statements (void)
{
_bfd_elf_linker_x86_set_options (&link_info, &params);
}
EOF
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=elf_x86_create_output_section_statements
if test -n "$CALL_NOP_BYTE"; then
fragment <<EOF
static void
elf_x86_before_parse (void)
{
params.call_nop_byte = $CALL_NOP_BYTE;
gld${EMULATION_NAME}_before_parse ();
}
EOF
LDEMUL_BEFORE_PARSE=elf_x86_before_parse
fi