1999-05-03 07:29:11 +00:00
|
|
|
|
# This shell script emits a C file. -*- C -*-
|
|
|
|
|
# It does some substitutions.
|
2001-09-03 07:29:50 +00:00
|
|
|
|
if [ -z "$MACHINE" ]; then
|
2001-05-25 05:39:22 +00:00
|
|
|
|
OUTPUT_ARCH=${ARCH}
|
|
|
|
|
else
|
|
|
|
|
OUTPUT_ARCH=${ARCH}:${MACHINE}
|
|
|
|
|
fi
|
2007-07-19 19:56:10 +00:00
|
|
|
|
fragment <<EOF
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* This file is part of GLD, the Gnu Linker.
|
2016-01-01 11:25:12 +00:00
|
|
|
|
Copyright (C) 1995-2016 Free Software Foundation, Inc.
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2007-07-06 14:09:45 +00:00
|
|
|
|
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; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
|
MA 02110-1301, USA. */
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* For WINDOWS_NT */
|
|
|
|
|
/* The original file generated returned different default scripts depending
|
|
|
|
|
on whether certain switches were set, but these switches pertain to the
|
|
|
|
|
Linux system and that particular version of coff. In the NT case, we
|
|
|
|
|
only determine if the subsystem is console or windows in order to select
|
2001-09-03 07:29:50 +00:00
|
|
|
|
the correct entry point by default. */
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#include "sysdep.h"
|
2007-04-26 14:47:00 +00:00
|
|
|
|
#include "bfd.h"
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#include "bfdlink.h"
|
|
|
|
|
#include "getopt.h"
|
|
|
|
|
#include "libiberty.h"
|
2011-02-28 18:34:52 +00:00
|
|
|
|
#include "filenames.h"
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#include "ld.h"
|
|
|
|
|
#include "ldmain.h"
|
|
|
|
|
#include "ldexp.h"
|
|
|
|
|
#include "ldlang.h"
|
2000-07-11 03:42:41 +00:00
|
|
|
|
#include "ldfile.h"
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#include "ldemul.h"
|
2002-10-30 03:57:39 +00:00
|
|
|
|
#include <ldgram.h>
|
1999-05-03 07:29:11 +00:00
|
|
|
|
#include "ldlex.h"
|
|
|
|
|
#include "ldmisc.h"
|
|
|
|
|
#include "ldctor.h"
|
|
|
|
|
#include "coff/internal.h"
|
|
|
|
|
#include "../bfd/libcoff.h"
|
|
|
|
|
|
|
|
|
|
#define TARGET_IS_${EMULATION_NAME}
|
|
|
|
|
|
|
|
|
|
static struct internal_extra_pe_aouthdr pe;
|
|
|
|
|
static int dll;
|
|
|
|
|
|
|
|
|
|
extern const char *output_filename;
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld_${EMULATION_NAME}_before_parse (void)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2004-01-03 11:09:07 +00:00
|
|
|
|
ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
|
2001-05-25 22:48:14 +00:00
|
|
|
|
output_filename = "a.exe";
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* PE format extra command line options. */
|
|
|
|
|
|
|
|
|
|
/* Used for setting flags in the PE header. */
|
|
|
|
|
#define OPTION_BASE_FILE (300 + 1)
|
|
|
|
|
#define OPTION_DLL (OPTION_BASE_FILE + 1)
|
|
|
|
|
#define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1)
|
|
|
|
|
#define OPTION_IMAGE_BASE (OPTION_FILE_ALIGNMENT + 1)
|
|
|
|
|
#define OPTION_MAJOR_IMAGE_VERSION (OPTION_IMAGE_BASE + 1)
|
|
|
|
|
#define OPTION_MAJOR_OS_VERSION (OPTION_MAJOR_IMAGE_VERSION + 1)
|
|
|
|
|
#define OPTION_MAJOR_SUBSYSTEM_VERSION (OPTION_MAJOR_OS_VERSION + 1)
|
|
|
|
|
#define OPTION_MINOR_IMAGE_VERSION (OPTION_MAJOR_SUBSYSTEM_VERSION + 1)
|
|
|
|
|
#define OPTION_MINOR_OS_VERSION (OPTION_MINOR_IMAGE_VERSION + 1)
|
|
|
|
|
#define OPTION_MINOR_SUBSYSTEM_VERSION (OPTION_MINOR_OS_VERSION + 1)
|
|
|
|
|
#define OPTION_SECTION_ALIGNMENT (OPTION_MINOR_SUBSYSTEM_VERSION + 1)
|
|
|
|
|
#define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1)
|
|
|
|
|
#define OPTION_SUBSYSTEM (OPTION_STACK + 1)
|
|
|
|
|
#define OPTION_HEAP (OPTION_SUBSYSTEM + 1)
|
|
|
|
|
|
2003-02-28 01:32:31 +00:00
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld${EMULATION_NAME}_add_options
|
|
|
|
|
(int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl,
|
|
|
|
|
struct option **longopts, int nrl ATTRIBUTE_UNUSED,
|
|
|
|
|
struct option **really_longopts ATTRIBUTE_UNUSED)
|
2003-02-28 01:32:31 +00:00
|
|
|
|
{
|
|
|
|
|
static const struct option xtra_long[] = {
|
|
|
|
|
/* PE options */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{"base-file", required_argument, NULL, OPTION_BASE_FILE},
|
|
|
|
|
{"dll", no_argument, NULL, OPTION_DLL},
|
|
|
|
|
{"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT},
|
2001-09-03 07:29:50 +00:00
|
|
|
|
{"heap", required_argument, NULL, OPTION_HEAP},
|
|
|
|
|
{"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION},
|
|
|
|
|
{"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION},
|
|
|
|
|
{"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION},
|
|
|
|
|
{"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION},
|
|
|
|
|
{"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION},
|
|
|
|
|
{"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION},
|
|
|
|
|
{"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT},
|
|
|
|
|
{"stack", required_argument, NULL, OPTION_STACK},
|
|
|
|
|
{"subsystem", required_argument, NULL, OPTION_SUBSYSTEM},
|
2003-02-28 01:32:31 +00:00
|
|
|
|
{NULL, no_argument, NULL, 0}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-28 01:32:31 +00:00
|
|
|
|
*longopts = (struct option *)
|
|
|
|
|
xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
|
|
|
|
|
memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* PE/WIN32; added routines to get the subsystem type, heap and/or stack
|
|
|
|
|
parameters which may be input from the command line */
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
void *ptr;
|
|
|
|
|
int size;
|
|
|
|
|
int value;
|
|
|
|
|
char *symbol;
|
|
|
|
|
int inited;
|
|
|
|
|
} definfo;
|
|
|
|
|
|
|
|
|
|
#define D(field,symbol,def) {&pe.field,sizeof(pe.field), def, symbol,0}
|
|
|
|
|
|
|
|
|
|
static definfo init[] =
|
|
|
|
|
{
|
|
|
|
|
/* imagebase must be first */
|
|
|
|
|
#define IMAGEBASEOFF 0
|
|
|
|
|
D(ImageBase,"__image_base__", BEOS_EXE_IMAGE_BASE),
|
|
|
|
|
#define DLLOFF 1
|
2001-08-03 19:19:42 +00:00
|
|
|
|
{&dll, sizeof(dll), 0, "__dll__", 0},
|
1999-05-03 07:29:11 +00:00
|
|
|
|
D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT),
|
|
|
|
|
D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT),
|
|
|
|
|
D(MajorOperatingSystemVersion,"__major_os_version__", 4),
|
|
|
|
|
D(MinorOperatingSystemVersion,"__minor_os_version__", 0),
|
|
|
|
|
D(MajorImageVersion,"__major_image_version__", 1),
|
|
|
|
|
D(MinorImageVersion,"__minor_image_version__", 0),
|
|
|
|
|
D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
|
|
|
|
|
D(MinorSubsystemVersion,"__minor_subsystem_version__", 0),
|
|
|
|
|
D(Subsystem,"__subsystem__", 3),
|
|
|
|
|
D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000),
|
|
|
|
|
D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000),
|
|
|
|
|
D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000),
|
|
|
|
|
D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000),
|
|
|
|
|
D(LoaderFlags,"__loader_flags__", 0x0),
|
|
|
|
|
{ NULL, 0, 0, NULL, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
set_pe_name (char *name, long val)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
/* Find the name and set it. */
|
|
|
|
|
for (i = 0; init[i].ptr; i++)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (name, init[i].symbol) == 0)
|
|
|
|
|
{
|
|
|
|
|
init[i].value = val;
|
|
|
|
|
init[i].inited = 1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
set_pe_subsystem (void)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
const char *sver;
|
|
|
|
|
int len;
|
|
|
|
|
int i;
|
2001-09-03 07:29:50 +00:00
|
|
|
|
static const struct
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
const int value;
|
|
|
|
|
const char *entry;
|
|
|
|
|
}
|
|
|
|
|
v[] =
|
|
|
|
|
{
|
|
|
|
|
{ "native", 1, "_NtProcessStartup" },
|
|
|
|
|
{ "windows", 2, "_WinMainCRTStartup" },
|
|
|
|
|
{ "wwindows", 2, "_wWinMainCRTStartup" },
|
|
|
|
|
{ "console", 3, "_mainCRTStartup" },
|
|
|
|
|
{ "wconsole", 3, "_wmainCRTStartup" },
|
|
|
|
|
{ "posix", 7, "___PosixProcessStartup"},
|
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sver = strchr (optarg, ':');
|
|
|
|
|
if (sver == NULL)
|
|
|
|
|
len = strlen (optarg);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
|
|
|
|
|
len = sver - optarg;
|
|
|
|
|
set_pe_name ("__major_subsystem_version__",
|
|
|
|
|
strtoul (sver + 1, &end, 0));
|
|
|
|
|
if (*end == '.')
|
|
|
|
|
set_pe_name ("__minor_subsystem_version__",
|
|
|
|
|
strtoul (end + 1, &end, 0));
|
|
|
|
|
if (*end != '\0')
|
|
|
|
|
einfo ("%P: warning: bad version number in -subsystem option\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; v[i].name; i++)
|
|
|
|
|
{
|
|
|
|
|
if (strncmp (optarg, v[i].name, len) == 0
|
|
|
|
|
&& v[i].name[len] == '\0')
|
|
|
|
|
{
|
|
|
|
|
set_pe_name ("__subsystem__", v[i].value);
|
|
|
|
|
|
|
|
|
|
/* If the subsystem is windows, we use a different entry
|
2005-06-01 04:04:19 +00:00
|
|
|
|
point. */
|
|
|
|
|
lang_default_entry (v[i].entry);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
einfo ("%P%F: invalid subsystem type %s\n", optarg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
set_pe_value (char *name)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
set_pe_name (name, strtoul (optarg, &end, 0));
|
|
|
|
|
if (end == optarg)
|
|
|
|
|
{
|
|
|
|
|
einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
optarg = end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
set_pe_stack_heap (char *resname, char *comname)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
set_pe_value (resname);
|
|
|
|
|
if (*optarg == ',')
|
|
|
|
|
{
|
|
|
|
|
optarg++;
|
|
|
|
|
set_pe_value (comname);
|
|
|
|
|
}
|
|
|
|
|
else if (*optarg)
|
|
|
|
|
{
|
|
|
|
|
einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-28 01:32:31 +00:00
|
|
|
|
static bfd_boolean
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld${EMULATION_NAME}_handle_option (int optc)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
switch (optc)
|
|
|
|
|
{
|
|
|
|
|
default:
|
2003-02-28 01:32:31 +00:00
|
|
|
|
return FALSE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
case OPTION_BASE_FILE:
|
2003-06-27 00:38:25 +00:00
|
|
|
|
link_info.base_file = fopen (optarg, FOPEN_WB);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (link_info.base_file == NULL)
|
2011-01-14 12:37:17 +00:00
|
|
|
|
einfo (_("%F%P: cannot open base file %s\n"), optarg);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
/* PE options */
|
2001-09-03 07:29:50 +00:00
|
|
|
|
case OPTION_HEAP:
|
1999-05-03 07:29:11 +00:00
|
|
|
|
set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__");
|
|
|
|
|
break;
|
2001-09-03 07:29:50 +00:00
|
|
|
|
case OPTION_STACK:
|
1999-05-03 07:29:11 +00:00
|
|
|
|
set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_SUBSYSTEM:
|
|
|
|
|
set_pe_subsystem ();
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_MAJOR_OS_VERSION:
|
|
|
|
|
set_pe_value ("__major_os_version__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_MINOR_OS_VERSION:
|
|
|
|
|
set_pe_value ("__minor_os_version__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_MAJOR_SUBSYSTEM_VERSION:
|
|
|
|
|
set_pe_value ("__major_subsystem_version__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_MINOR_SUBSYSTEM_VERSION:
|
|
|
|
|
set_pe_value ("__minor_subsystem_version__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_MAJOR_IMAGE_VERSION:
|
|
|
|
|
set_pe_value ("__major_image_version__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_MINOR_IMAGE_VERSION:
|
|
|
|
|
set_pe_value ("__minor_image_version__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_FILE_ALIGNMENT:
|
|
|
|
|
set_pe_value ("__file_alignment__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_SECTION_ALIGNMENT:
|
|
|
|
|
set_pe_value ("__section_alignment__");
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_DLL:
|
|
|
|
|
set_pe_name ("__dll__", 1);
|
|
|
|
|
break;
|
|
|
|
|
case OPTION_IMAGE_BASE:
|
|
|
|
|
set_pe_value ("__image_base__");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-02-28 01:32:31 +00:00
|
|
|
|
return TRUE;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Assign values to the special symbols before the linker script is
|
|
|
|
|
read. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld_${EMULATION_NAME}_set_symbols (void)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
/* Run through and invent symbols for all the
|
|
|
|
|
names and insert the defaults. */
|
|
|
|
|
int j;
|
|
|
|
|
|
|
|
|
|
if (!init[IMAGEBASEOFF].inited)
|
|
|
|
|
{
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 12:51:03 +00:00
|
|
|
|
if (bfd_link_relocatable (&link_info))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
init[IMAGEBASEOFF].value = 0;
|
|
|
|
|
else if (init[DLLOFF].value)
|
|
|
|
|
init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE;
|
|
|
|
|
else
|
|
|
|
|
init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-25 06:40:27 +00:00
|
|
|
|
/* Don't do any symbol assignments if this is a relocatable link. */
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 12:51:03 +00:00
|
|
|
|
if (bfd_link_relocatable (&link_info))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Glue the assignments into the abs section */
|
2009-02-16 07:25:52 +00:00
|
|
|
|
push_stat_ptr (&abs_output_section->children);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
for (j = 0; init[j].ptr; j++)
|
|
|
|
|
{
|
|
|
|
|
long val = init[j].value;
|
2012-08-06 22:27:52 +00:00
|
|
|
|
lang_add_assignment (exp_assign (init[j].symbol, exp_intop (val),
|
|
|
|
|
FALSE));
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (init[j].size == sizeof(short))
|
|
|
|
|
*(short *)init[j].ptr = val;
|
|
|
|
|
else if (init[j].size == sizeof(int))
|
|
|
|
|
*(int *)init[j].ptr = val;
|
|
|
|
|
else if (init[j].size == sizeof(long))
|
|
|
|
|
*(long *)init[j].ptr = val;
|
|
|
|
|
/* This might be a long long or other special type. */
|
|
|
|
|
else if (init[j].size == sizeof(bfd_vma))
|
|
|
|
|
*(bfd_vma *)init[j].ptr = val;
|
|
|
|
|
else abort();
|
|
|
|
|
}
|
|
|
|
|
/* Restore the pointer. */
|
2009-02-16 07:25:52 +00:00
|
|
|
|
pop_stat_ptr ();
|
2001-09-03 07:29:50 +00:00
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (pe.FileAlignment >
|
|
|
|
|
pe.SectionAlignment)
|
|
|
|
|
{
|
|
|
|
|
einfo ("%P: warning, file alignment > section alignment.\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld_${EMULATION_NAME}_after_open (void)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
* ld.texinfo (Expression Section): Describe treatment of numbers
and absolute symbols.
* ldemul.c (after_open_default): Look up __ld_compatibility.
* ldexp.c (fold_name): Convert absolute symbols to numbers when
inside output section definitions, or when __ld_compatibility >= 221.
(exp_fold_tree_1): Convert numbers to absolute when not in output
section definition and __ld_compatibility < 221. Don't always
convert values outside an output section definition to absolute.
* ldexp.h (uses_defined): Comment.
* ldlang.c (ld_compatibility): New variable.
* ldlang.h (ld_compatibility): Declare.
* emultempl/aix.em, * emultempl/armcoff.em, * emultempl/beos.em,
* emultempl/elf32.em, * emultempl/genelf.em, * emultempl/lnk960.em,
* emultempl/m68kcoff.em, * emultempl/mmo.em, * emultempl/pe.em,
* emultempl/pep.em, * emultempl/sunos.em, * emultempl/z80.em: Call
after_open_default from after_open function.
2010-12-20 13:00:14 +00:00
|
|
|
|
after_open_default ();
|
|
|
|
|
|
1999-05-03 07:29:11 +00:00
|
|
|
|
/* Pass the wacky PE command line options into the output bfd.
|
|
|
|
|
FIXME: This should be done via a function, rather than by
|
|
|
|
|
including an internal BFD header. */
|
2008-02-15 03:35:53 +00:00
|
|
|
|
if (!coff_data(link_info.output_bfd)->pe)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
einfo ("%F%P: PE operations on non PE file.\n");
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-15 03:35:53 +00:00
|
|
|
|
pe_data(link_info.output_bfd)->pe_opthdr = pe;
|
|
|
|
|
pe_data(link_info.output_bfd)->dll = init[DLLOFF].value;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Callback functions for qsort in sort_sections. */
|
|
|
|
|
|
|
|
|
|
static int
|
2003-06-27 00:38:25 +00:00
|
|
|
|
sort_by_file_name (const void *a, const void *b)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-09-18 10:10:21 +00:00
|
|
|
|
const lang_statement_union_type *const *ra = a;
|
|
|
|
|
const lang_statement_union_type *const *rb = b;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
int i, a_sec, b_sec;
|
|
|
|
|
|
2011-02-28 18:34:52 +00:00
|
|
|
|
i = filename_cmp ((*ra)->input_section.section->owner->my_archive->filename,
|
|
|
|
|
(*rb)->input_section.section->owner->my_archive->filename);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (i != 0)
|
|
|
|
|
return i;
|
|
|
|
|
|
2011-02-28 18:34:52 +00:00
|
|
|
|
i = filename_cmp ((*ra)->input_section.section->owner->filename,
|
|
|
|
|
(*rb)->input_section.section->owner->filename);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
if (i != 0)
|
|
|
|
|
return i;
|
|
|
|
|
/* the tail idata4/5 are the only ones without relocs to an
|
2001-09-03 07:29:50 +00:00
|
|
|
|
idata$6 section unless we are importing by ordinal,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
so sort them to last to terminate the IAT
|
|
|
|
|
and HNT properly. if no reloc this one is import by ordinal
|
|
|
|
|
so we have to sort by section contents */
|
|
|
|
|
|
|
|
|
|
if ( ((*ra)->input_section.section->reloc_count + (*rb)->input_section.section->reloc_count) )
|
|
|
|
|
{
|
2001-09-03 07:29:50 +00:00
|
|
|
|
i = (((*ra)->input_section.section->reloc_count >
|
1999-05-03 07:29:11 +00:00
|
|
|
|
(*rb)->input_section.section->reloc_count) ? -1 : 0);
|
|
|
|
|
if ( i != 0)
|
|
|
|
|
return i;
|
|
|
|
|
|
2001-09-03 07:29:50 +00:00
|
|
|
|
return (((*ra)->input_section.section->reloc_count >
|
1999-05-03 07:29:11 +00:00
|
|
|
|
(*rb)->input_section.section->reloc_count) ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( (strcmp( (*ra)->input_section.section->name, ".idata$6") == 0) )
|
|
|
|
|
return 0; /* don't sort .idata$6 or .idata$7 FIXME dlltool eliminate .idata$7 */
|
|
|
|
|
|
2005-11-17 00:10:05 +00:00
|
|
|
|
if (! bfd_get_section_contents ((*ra)->input_section.section->owner,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
(*ra)->input_section.section, &a_sec, (file_ptr) 0, (bfd_size_type)sizeof(a_sec)))
|
|
|
|
|
einfo ("%F%B: Can't read contents of section .idata: %E\n",
|
2005-11-17 00:10:05 +00:00
|
|
|
|
(*ra)->input_section.section->owner);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2005-11-17 00:10:05 +00:00
|
|
|
|
if (! bfd_get_section_contents ((*rb)->input_section.section->owner,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
(*rb)->input_section.section, &b_sec, (file_ptr) 0, (bfd_size_type)sizeof(b_sec) ))
|
|
|
|
|
einfo ("%F%B: Can't read contents of section .idata: %E\n",
|
2005-11-17 00:10:05 +00:00
|
|
|
|
(*rb)->input_section.section->owner);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
i = ((a_sec < b_sec) ? -1 : 0);
|
|
|
|
|
if ( i != 0)
|
|
|
|
|
return i;
|
|
|
|
|
return ((a_sec < b_sec) ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
2003-06-27 00:38:25 +00:00
|
|
|
|
sort_by_section_name (const void *a, const void *b)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-09-18 10:10:21 +00:00
|
|
|
|
const lang_statement_union_type *const *ra = a;
|
|
|
|
|
const lang_statement_union_type *const *rb = b;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
int i;
|
|
|
|
|
i = strcmp ((*ra)->input_section.section->name,
|
2006-09-16 18:12:17 +00:00
|
|
|
|
(*rb)->input_section.section->name);
|
|
|
|
|
/* This is a hack to make .stab and .stabstr last, so we don't have
|
|
|
|
|
to fix strip/objcopy for .reloc sections.
|
|
|
|
|
FIXME stripping images with a .rsrc section still needs to be fixed. */
|
|
|
|
|
if (i != 0)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2006-09-16 18:12:17 +00:00
|
|
|
|
if ((CONST_STRNEQ ((*ra)->input_section.section->name, ".stab"))
|
|
|
|
|
&& (! CONST_STRNEQ ((*rb)->input_section.section->name, ".stab")))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Subroutine of sort_sections to a contiguous subset of a list of sections.
|
|
|
|
|
NEXT_AFTER is the element after the last one to sort.
|
|
|
|
|
The result is a pointer to the last element's "next" pointer. */
|
|
|
|
|
|
|
|
|
|
static lang_statement_union_type **
|
2003-06-27 00:38:25 +00:00
|
|
|
|
sort_sections_1 (lang_statement_union_type **startptr,
|
|
|
|
|
lang_statement_union_type *next_after,
|
|
|
|
|
int count,
|
|
|
|
|
int (*sort_func) (const void *, const void *))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
lang_statement_union_type **vec;
|
|
|
|
|
lang_statement_union_type *p;
|
|
|
|
|
int i;
|
|
|
|
|
lang_statement_union_type **ret;
|
|
|
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
|
return startptr;
|
|
|
|
|
|
|
|
|
|
vec = ((lang_statement_union_type **)
|
|
|
|
|
xmalloc (count * sizeof (lang_statement_union_type *)));
|
|
|
|
|
|
2001-08-20 02:14:50 +00:00
|
|
|
|
for (p = *startptr, i = 0; i < count; i++, p = p->header.next)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
vec[i] = p;
|
|
|
|
|
|
|
|
|
|
qsort (vec, count, sizeof (vec[0]), sort_func);
|
|
|
|
|
|
|
|
|
|
/* Fill in the next pointers again. */
|
|
|
|
|
*startptr = vec[0];
|
|
|
|
|
for (i = 0; i < count - 1; i++)
|
|
|
|
|
vec[i]->header.next = vec[i + 1];
|
|
|
|
|
vec[i]->header.next = next_after;
|
|
|
|
|
ret = &vec[i]->header.next;
|
|
|
|
|
free (vec);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sort the .idata\$foo input sections of archives into filename order.
|
|
|
|
|
The reason is so dlltool can arrange to have the pe dll import information
|
|
|
|
|
generated correctly - the head of the list goes into dh.o, the tail into
|
|
|
|
|
dt.o, and the guts into ds[nnnn].o. Note that this is only needed for the
|
|
|
|
|
.idata section.
|
|
|
|
|
FIXME: This may no longer be necessary with grouped sections. Instead of
|
|
|
|
|
sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use
|
|
|
|
|
.idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t.
|
|
|
|
|
This would have to be elaborated upon to handle multiple dll's
|
|
|
|
|
[assuming such an eloboration is possible of course].
|
|
|
|
|
|
|
|
|
|
We also sort sections in '\$' wild statements. These are created by the
|
|
|
|
|
place_orphans routine to implement grouped sections. */
|
|
|
|
|
|
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
sort_sections (lang_statement_union_type *s)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-20 02:14:50 +00:00
|
|
|
|
for (; s ; s = s->header.next)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
switch (s->header.type)
|
|
|
|
|
{
|
|
|
|
|
case lang_output_section_statement_enum:
|
|
|
|
|
sort_sections (s->output_section_statement.children.head);
|
|
|
|
|
break;
|
|
|
|
|
case lang_wild_statement_enum:
|
|
|
|
|
{
|
|
|
|
|
lang_statement_union_type **p = &s->wild_statement.children.head;
|
2001-08-04 01:21:43 +00:00
|
|
|
|
struct wildcard_list *sec;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-04 01:21:43 +00:00
|
|
|
|
for (sec = s->wild_statement.section_list; sec; sec = sec->next)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-04 01:21:43 +00:00
|
|
|
|
/* Is this the .idata section? */
|
|
|
|
|
if (sec->spec.name != NULL
|
2006-09-16 18:12:17 +00:00
|
|
|
|
&& CONST_STRNEQ (sec->spec.name, ".idata"))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-04 01:21:43 +00:00
|
|
|
|
/* Sort the children. We want to sort any objects in
|
|
|
|
|
the same archive. In order to handle the case of
|
|
|
|
|
including a single archive multiple times, we sort
|
|
|
|
|
all the children by archive name and then by object
|
|
|
|
|
name. After sorting them, we re-thread the pointer
|
|
|
|
|
chain. */
|
|
|
|
|
|
|
|
|
|
while (*p)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-04 01:21:43 +00:00
|
|
|
|
lang_statement_union_type *start = *p;
|
|
|
|
|
if (start->header.type != lang_input_section_enum
|
2005-11-17 00:10:05 +00:00
|
|
|
|
|| !start->input_section.section->owner->my_archive)
|
2001-08-04 01:21:43 +00:00
|
|
|
|
p = &(start->header.next);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lang_statement_union_type *end;
|
|
|
|
|
int count;
|
|
|
|
|
|
|
|
|
|
for (end = start, count = 0;
|
|
|
|
|
end && (end->header.type
|
|
|
|
|
== lang_input_section_enum);
|
2001-08-20 02:14:50 +00:00
|
|
|
|
end = end->header.next)
|
2001-08-04 01:21:43 +00:00
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
p = sort_sections_1 (p, end, count,
|
|
|
|
|
sort_by_file_name);
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
2001-08-04 01:21:43 +00:00
|
|
|
|
break;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-04 01:21:43 +00:00
|
|
|
|
/* If this is a collection of grouped sections, sort them.
|
|
|
|
|
The linker script must explicitly mention "*(.foo\$)" or
|
|
|
|
|
"*(.foo\$*)". Don't sort them if \$ is not the last
|
|
|
|
|
character (not sure if this is really useful, but it
|
|
|
|
|
allows explicitly mentioning some \$ sections and letting
|
|
|
|
|
the linker handle the rest). */
|
|
|
|
|
if (sec->spec.name != NULL)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-04 01:21:43 +00:00
|
|
|
|
char *q = strchr (sec->spec.name, '\$');
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2001-08-04 01:21:43 +00:00
|
|
|
|
if (q != NULL
|
|
|
|
|
&& (q[1] == '\0'
|
|
|
|
|
|| (q[1] == '*' && q[2] == '\0')))
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
2001-08-04 01:21:43 +00:00
|
|
|
|
lang_statement_union_type *end;
|
|
|
|
|
int count;
|
|
|
|
|
|
2001-08-20 02:14:50 +00:00
|
|
|
|
for (end = *p, count = 0; end; end = end->header.next)
|
2001-08-04 01:21:43 +00:00
|
|
|
|
{
|
|
|
|
|
if (end->header.type != lang_input_section_enum)
|
|
|
|
|
abort ();
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
(void) sort_sections_1 (p, end, count,
|
|
|
|
|
sort_by_section_name);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
2001-08-04 01:21:43 +00:00
|
|
|
|
break;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-03 07:29:50 +00:00
|
|
|
|
static void
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld_${EMULATION_NAME}_before_allocation (void)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef TARGET_IS_ppcpe
|
|
|
|
|
/* Here we rummage through the found bfds to collect toc information */
|
|
|
|
|
{
|
|
|
|
|
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
|
|
|
|
{
|
|
|
|
|
if (!ppc_process_before_allocation(is->the_bfd, &link_info))
|
|
|
|
|
{
|
|
|
|
|
einfo("Errors encountered processing file %s\n", is->filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We have seen it all. Allocate it, and carry on */
|
|
|
|
|
ppc_allocate_toc_section (&link_info);
|
|
|
|
|
#else
|
|
|
|
|
#ifdef TARGET_IS_armpe
|
|
|
|
|
/* FIXME: we should be able to set the size of the interworking stub
|
|
|
|
|
section.
|
|
|
|
|
|
|
|
|
|
Here we rummage through the found bfds to collect glue
|
|
|
|
|
information. FIXME: should this be based on a command line
|
|
|
|
|
option? krk@cygnus.com */
|
|
|
|
|
{
|
|
|
|
|
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
|
|
|
|
{
|
|
|
|
|
if (!arm_process_before_allocation (is->the_bfd, & link_info))
|
|
|
|
|
{
|
|
|
|
|
einfo ("Errors encountered processing file %s", is->filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We have seen it all. Allocate it, and carry on */
|
|
|
|
|
arm_allocate_interworking_sections (& link_info);
|
|
|
|
|
#endif /* TARGET_IS_armpe */
|
|
|
|
|
#endif /* TARGET_IS_ppcpe */
|
|
|
|
|
|
|
|
|
|
sort_sections (stat_ptr->head);
|
2005-05-04 11:00:28 +00:00
|
|
|
|
|
2005-08-04 01:19:10 +00:00
|
|
|
|
before_allocation_default ();
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Place an orphan section. We use this to put sections with a '\$' in them
|
|
|
|
|
into the right place. Any section with a '\$' in them (e.g. .text\$foo)
|
|
|
|
|
gets mapped to the output section with everything from the '\$' on stripped
|
|
|
|
|
(e.g. .text).
|
|
|
|
|
See the Microsoft Portable Executable and Common Object File Format
|
|
|
|
|
Specification 4.1, section 4.2, Grouped Sections.
|
|
|
|
|
|
|
|
|
|
FIXME: This is now handled by the linker script using wildcards,
|
|
|
|
|
but I'm leaving this here in case we want to enable it for sections
|
|
|
|
|
which are not mentioned in the linker script. */
|
|
|
|
|
|
2008-10-20 12:14:29 +00:00
|
|
|
|
static lang_output_section_statement_type *
|
2008-10-04 06:08:59 +00:00
|
|
|
|
gld${EMULATION_NAME}_place_orphan (asection *s,
|
|
|
|
|
const char *secname,
|
|
|
|
|
int constraint)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
char *output_secname, *ps;
|
|
|
|
|
lang_output_section_statement_type *os;
|
|
|
|
|
lang_statement_union_type *l;
|
|
|
|
|
|
|
|
|
|
if ((s->flags & SEC_ALLOC) == 0)
|
2008-10-20 12:14:29 +00:00
|
|
|
|
return NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Don't process grouped sections unless doing a final link.
|
|
|
|
|
If they're marked as COMDAT sections, we don't want .text\$foo to
|
|
|
|
|
end up in .text and then have .text disappear because it's marked
|
|
|
|
|
link-once-discard. */
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 12:51:03 +00:00
|
|
|
|
if (bfd_link_relocatable (&link_info))
|
2008-10-20 12:14:29 +00:00
|
|
|
|
return NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Everything from the '\$' on gets deleted so don't allow '\$' as the
|
|
|
|
|
first character. */
|
|
|
|
|
if (*secname == '\$')
|
|
|
|
|
einfo ("%P%F: section %s has '\$' as first character\n", secname);
|
|
|
|
|
if (strchr (secname + 1, '\$') == NULL)
|
2008-10-20 12:14:29 +00:00
|
|
|
|
return NULL;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Look up the output section. The Microsoft specs say sections names in
|
|
|
|
|
image files never contain a '\$'. Fortunately, lang_..._lookup creates
|
|
|
|
|
the section if it doesn't exist. */
|
2001-05-02 18:14:31 +00:00
|
|
|
|
output_secname = xstrdup (secname);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
ps = strchr (output_secname + 1, '\$');
|
|
|
|
|
*ps = 0;
|
2008-10-04 06:08:59 +00:00
|
|
|
|
os = lang_output_section_statement_lookup (output_secname, constraint, TRUE);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
/* Find the '\$' wild statement for this section. We currently require the
|
|
|
|
|
linker script to explicitly mention "*(.foo\$)".
|
|
|
|
|
FIXME: ppcpe.sc has .CRT\$foo in the .rdata section. According to the
|
|
|
|
|
Microsoft docs this isn't correct so it's not (currently) handled. */
|
|
|
|
|
|
|
|
|
|
ps[0] = '\$';
|
|
|
|
|
ps[1] = 0;
|
2001-08-20 02:14:50 +00:00
|
|
|
|
for (l = os->children.head; l; l = l->header.next)
|
2001-08-04 01:21:43 +00:00
|
|
|
|
if (l->header.type == lang_wild_statement_enum)
|
|
|
|
|
{
|
|
|
|
|
struct wildcard_list *sec;
|
|
|
|
|
|
|
|
|
|
for (sec = l->wild_statement.section_list; sec; sec = sec->next)
|
|
|
|
|
if (sec->spec.name && strcmp (sec->spec.name, output_secname) == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (sec)
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-05-03 07:29:11 +00:00
|
|
|
|
ps[0] = 0;
|
|
|
|
|
if (l == NULL)
|
|
|
|
|
einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname);
|
|
|
|
|
|
|
|
|
|
/* Link the input section in and we're done for now.
|
|
|
|
|
The sections still have to be sorted, but that has to wait until
|
|
|
|
|
all such sections have been processed by us. The sorting is done by
|
|
|
|
|
sort_sections. */
|
Add support for PowerPC VLE.
2012-05-14 Catherine Moore <clm@codesourcery.com>
* NEWS: Mention PowerPC VLE port.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
Catherine Moore <clm@codesourcery.com>
bfd/
* bfd.c (bfd_lookup_section_flags): Add section parm.
* ecoff.c (bfd_debug_section): Remove flag_info initializer.
* elf-bfd.h (bfd_elf_section_data): Move in section_flag_info.
(bfd_elf_lookup_section_flags): Add section parm.
* elf32-ppc.c (is_ppc_vle): New function.
(ppc_elf_modify_segment_map): New function.
(elf_backend_modify_segment_map): Define.
(has_vle_insns): New define.
* elf32-ppc.h (ppc_elf_modify_segment_map): Declare.
* elflink.c (bfd_elf_lookup_section_flags): Add return value & parm.
Move in logic to omit / include a section.
* libbfd-in.h (bfd_link_info): Add section parm.
(bfd_generic_lookup_section_flags): Likewise.
* reloc.c (bfd_generic_lookup_section_flags): Likewise.
* section.c (bfd_section): Move out section_flag_info.
(BFD_FAKE_SECTION): Remove flag_info initializer.
* targets.c (_bfd_lookup_section_flags): Add section parm.
2012-05-14 Catherine Moore <clm@codesourcery.com>
bfd/
* archures.c (bfd_mach_ppc_vle): New.
* bfd-in2.h: Regenerated.
* cpu-powerpc.c (bfd_powerpc_archs): New entry for vle.
* elf32-ppc.c (split16_format_type): New enumeration.
(ppc_elf_vle_split16): New function.
(HOWTO): Add entries for R_PPC_VLE relocations.
(ppc_elf_reloc_type_lookup): Handle PPC_VLE relocations.
(ppc_elf_section_flags): New function.
(ppc_elf_lookup_section_flags): New function.
(ppc_elf_section_processing): New function.
(ppc_elf_check_relocs): Handle PPC_VLE relocations.
(ppc_elf_relocation_section): Likewise.
(elf_backend_lookup_section_flags_hook): Define.
(elf_backend_section_flags): Define.
(elf_backend_section_processing): Define.
* elf32-ppc.h (ppc_elf_section_processing): Declare.
* libbfd.h: Regenerated.
* reloc.c (BFD_RELOC_PPC_VLE_REL8, BFD_RELOC_PPC_VLE_REL15,
BFD_RELOC_PPC_VLE_REL24, BFD_RELOC_PPC_VLE_LO16A,
BFD_RELOC_PPC_VLE_LO16D, BFD_RELOC_PPC_VLE_HI16A,
BFD_RELOC_PPC_VLE_HI16D, BFD_RELOC_PPC_VLE_HA16A,
BFD_RELOC_PPC_VLE_HA16D, BFD_RELOC_PPC_VLE_SDA21,
BFD_RELOC_PPC_VLE_SDA21_LO, BFD_RELOC_PPC_VLE_SDAREL_LO16A,
BFD_RELOC_PPC_VLE_SDAREL_LO16D, BFD_RELOC_PPC_VLE_SDAREL_HI16A,
BFD_RELOC_PPC_VLE_SDAREL_HI16D, BFD_RELOC_PPC_VLE_SDAREL_HA16A,
BFD_RELOC_PPC_VLE_SDAREL_HA16D): New bfd relocations.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
gas/
* config/tc-ppc.c (insn_validate): New func of existing code to call..
(ppc_setup_opcodes): ..from 2 places here.
Revise for second (VLE) opcode table.
Add #ifdef'd code to print opcode tables.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
gas/
* config/tc-ppc.c (ppc_setup_opcodes): Allow out-of-order
for the VLE conditional branches.
2012-05-14 Catherine Moore <clm@codesourcery.com>
Maciej W. Rozycki <macro@codesourcery.com>
Rhonda Wittels <rhonda@codesourcery.com>
gas/
* config/tc-ppc.c (PPC_VLE_SPLIT16A): New macro.
(PPC_VLE_SPLIT16D): New macro.
(PPC_VLE_LO16A): New macro.
(PPC_VLE_LO16D): New macro.
(PPC_VLE_HI16A): New macro.
(PPC_VLE_HI16D): New macro.
(PPC_VLE_HA16A): New macro.
(PPC_VLE_HA16D): New macro.
(PPC_APUINFO_VLE): New definition.
(md_chars_to_number): New function.
(md_parse_option): Check for combinations of little
endian and -mvle.
(md_show_usage): Document -mvle.
(ppc_arch): Recognize VLE.
(ppc_mach): Recognize bfd_mach_ppc_vle.
(ppc_setup_opcodes): Print the opcode table if
* config/tc-ppc.h (ppc_frag_check): Declare.
* doc/c-ppc.texi: Document -mvle.
* NEWS: Mention PowerPC VLE port.
2012-05-14 Catherine Moore <clm@codesourcery.com>
gas/
* config/tc-ppc.h (ppc_dw2_line_min_insn_length): Declare.
(DWARF2_LINE_MIN_INSN_LENGTH): Redefine.
* config/tc-ppc.c (ppc_dw2_line_min_insn_length): New.
* dwarf2dbg.c (scale_addr_delta): Handle values of 1
for DWARF2_LINE_MIN_INSN_LENGTH.
2012-05-14 Catherine Moore <clm@codesourcery.com>
Maciej W. Rozycki <macro@codesourcery.com>
Rhonda Wittels <rhonda@codesourcery.com>
gas/testsuite/
* gas/ppc/ppc.exp: Run new tests.
* gas/ppc/vle-reloc.d: New test.
* gas/ppc/vle-reloc.s: New test.
* gas/ppc/vle-simple-1.d: New test.
* gas/ppc/vle-simple-1.s: New test.
* gas/ppc/vle-simple-2.d: New test.
* gas/ppc/vle-simple-2.s: New test.
* gas/ppc/vle-simple-3.d: New test.
* gas/ppc/vle-simple-3.s: New test.
* gas/ppc/vle-simple-4.d: New test.
* gas/ppc/vle-simple-4.s: New test.
* gas/ppc/vle-simple-5.d: New test.
* gas/ppc/vle-simple-5.s: New test.
* gas/ppc/vle-simple-6.d: New test.
* gas/ppc/vle-simple-6.s: New test.
* gas/ppc/vle.d: New test.
* gas/ppc/vle.s: New test.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
include/elf/
* ppc.h (SEC_PPC_VLE): Remove.
2012-05-14 Catherine Moore <clm@codesourcery.com>
James Lemke <jwlemke@codesourcery.com>
include/elf/
* ppc.h (R_PPC_VLE_REL8): New reloction.
(R_PPC_VLE_REL15): Likewise.
(R_PPC_VLE_REL24): Likewise.
(R_PPC_VLE_LO16A): Likewise.
(R_PPC_VLE_LO16D): Likewise.
(R_PPC_VLE_HI16A): Likewise.
(R_PPC_VLE_HI16D): Likewise.
(R_PPC_VLE_HA16A): Likewise.
(R_PPC_VLE_HA16D): Likewise.
(R_PPC_VLE_SDA21): Likewise.
(R_PPC_VLE_SDA21_LO): Likewise.
(R_PPC_VLE_SDAREL_LO16A): Likewise.
(R_PPC_VLE_SDAREL_LO16D): Likewise.
(R_PPC_VLE_SDAREL_HI16A): Likewise.
(R_PPC_VLE_SDAREL_HI16D): Likewise.
(R_PPC_VLE_SDAREL_HA16A): Likewise.
(R_PPC_VLE_SDAREL_HA16D): Likewise.
(SEC_PPC_VLE): Remove.
(PF_PPC_VLE): New program header flag.
(SHF_PPC_VLE): New section header flag.
(vle_opcodes, vle_num_opcodes): New.
(VLE_OP): New macro.
(VLE_OP_TO_SEG): New macro.
2012-05-14 Catherine Moore <clm@codesourcery.com>
Maciej W. Rozycki <macro@codesourcery.com>
Rhonda Wittels <rhonda@codesourcery.com>
include/opcode/
* ppc.h (PPC_OPCODE_VLE): New definition.
(PPC_OP_SA): New macro.
(PPC_OP_SE_VLE): New macro.
(PPC_OP): Use a variable shift amount.
(powerpc_operand): Update comments.
(PPC_OPSHIFT_INV): New macro.
(PPC_OPERAND_CR): Replace with...
(PPC_OPERAND_CR_BIT): ...this and
(PPC_OPERAND_CR_REG): ...this.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
ld/
* ldlang.c (walk_wild_consider_section): Don't copy section_flag_list.
Pass it to callback.
(walk_wild_section_general): Pass section_flag_list to callback.
(lang_add_section): Add sflag_list parm.
Move out logic to keep / omit a section & call bfd_lookup_section_flags.
(output_section_callback_fast): Add sflag_list parm.
Add new parm to lang_add_section calls.
(output_section_callback): Likewise.
(check_section_callback): Add sflag_list parm.
(lang_place_orphans): Add new parm to lang_add_section calls.
(gc_section_callback): Add sflag_list parm.
(find_relro_section_callback): Likewise.
* ldlang.h (callback_t): Add flag_info parm.
(lang_add_section): Add sflag_list parm.
* emultempl/armelf.em (elf32_arm_add_stub_section):
Add lang_add_section parm.
* emultempl/beos.em (gld*_place_orphan): Likewise.
* emultempl/elf32.em (gld*_place_orphan): Likewise.
* emultempl/hppaelf.em (hppaelf_add_stub_section): Likewise.
* emultempl/m68hc1xelf.em (m68hc11elf_add_stub_section): Likewise.
* emultempl/mipself.em (mips_add_stub_section): Likewise.
* emultempl/mmo.em (mmo_place_orphan): Likewise.
* emultempl/pe.em (gld_*_place_orphan): Likewise.
* emultempl/pep.em (gld_*_place_orphan): Likewise.
* emultempl/ppc64elf.em (ppc_add_stub_section): Likewise.
* emultempl/spuelf.em (spu_place_special_section): Likewise.
* emultempl/vms.em (vms_place_orphan): Likewise.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
ld/testsuite/
* ld-powerpc/powerpc.exp: Create ppceabitests.
* ld-powerpc/vle-multiseg.s: New.
* ld-powerpc/vle-multiseg-1.d: New.
* ld-powerpc/vle-multiseg-1.ld: New.
* ld-powerpc/vle-multiseg-2.d: New.
* ld-powerpc/vle-multiseg-2.ld: New.
* ld-powerpc/vle-multiseg-3.d: New.
* ld-powerpc/vle-multiseg-3.ld: New.
* ld-powerpc/vle-multiseg-4.d: New.
* ld-powerpc/vle-multiseg-4.ld: New.
* ld-powerpc/vle-multiseg-5.d: New.
* ld-powerpc/vle-multiseg-5.ld: New.
* ld-powerpc/vle-multiseg-6.d: New.
* ld-powerpc/vle-multiseg-6.ld: New.
* ld-powerpc/vle-multiseg-6a.s: New.
* ld-powerpc/vle-multiseg-6b.s: New.
* ld-powerpc/vle-multiseg-6c.s: New.
* ld-powerpc/vle-multiseg-6d.s: New.
* ld-powerpc/powerpc.exp: Run new tests.
2012-05-14 Catherine Moore <clm@codesourcery.com>
ld/
* NEWS: Mention PowerPC VLE port.
2012-05-14 Catherine Moore <clm@codesourcery.com>
ld/testsuite/
* ld-powerpc/apuinfo.rd: Update for VLE.
* ld-powerpc/vle-reloc-1.d: New.
* ld-powerpc/vle-reloc-1.s: New.
* ld-powerpc/vle-reloc-2.d: New.
* ld-powerpc/vle-reloc-2.s: New.
* ld-powerpc/vle-reloc-3.d: New.
* ld-powerpc/vle-reloc-3.s: New.
* ld-powerpc/vle-reloc-def-1.s: New.
* ld-powerpc/vle-reloc-def-2.s: New.
* ld-powerpc/vle-reloc-def-3.s: New.
2012-05-14 James Lemke <jwlemke@codesourcery.com>
opcodes/
* ppc-dis.c (get_powerpc_dialect): Use is_ppc_vle.
(PPC_OPCD_SEGS, VLE_OPCD_SEGS): New defines.
(vle_opcd_indices): New array.
(lookup_vle): New function.
(disassemble_init_powerpc): Revise for second (VLE) opcode table.
(print_insn_powerpc): Likewise.
* ppc-opc.c: Likewise.
2012-05-14 Catherine Moore <clm@codesourcery.com>
Maciej W. Rozycki <macro@codesourcery.com>
Rhonda Wittels <rhonda@codesourcery.com>
Nathan Froyd <froydnj@codesourcery.com>
opcodes/
* ppc-opc.c (insert_arx, extract_arx): New functions.
(insert_ary, extract_ary): New functions.
(insert_li20, extract_li20): New functions.
(insert_rx, extract_rx): New functions.
(insert_ry, extract_ry): New functions.
(insert_sci8, extract_sci8): New functions.
(insert_sci8n, extract_sci8n): New functions.
(insert_sd4h, extract_sd4h): New functions.
(insert_sd4w, extract_sd4w): New functions.
(insert_vlesi, extract_vlesi): New functions.
(insert_vlensi, extract_vlensi): New functions.
(insert_vleui, extract_vleui): New functions.
(insert_vleil, extract_vleil): New functions.
(BI_MASK, BB_MASK, BT): Use PPC_OPERAND_CR_BIT.
(BI16, BI32, BO32, B8): New.
(B15, B24, CRD32, CRS): New.
(CRD, OBF, BFA, CR, CRFS): Use PPC_OPERAND_CR_REG.
(DB, IMM20, RD, Rx, ARX, RY, RZ): New.
(ARY, SCLSCI8, SCLSCI8N, SE_SD, SE_SDH): New.
(SH6_MASK): Use PPC_OPSHIFT_INV.
(SI8, UI5, OIMM5, UI7, BO16): New.
(VLESIMM, VLENSIMM, VLEUIMM, VLEUIMML): New.
(XT6, XA6, XB6, XB6S, XC6): Use PPC_OPSHIFT_INV.
(ALLOW8_SPRG): New.
(insert_sprg, extract_sprg): Check ALLOW8_SPRG.
(OPVUP, OPVUP_MASK OPVUP): New
(BD8, BD8_MASK, BD8IO, BD8IO_MASK): New.
(EBD8IO, EBD8IO1_MASK, EBD8IO2_MASK, EBD8IO3_MASK): New.
(BD15, BD15_MASK, EBD15, EBD15_MASK, EBD15BI, EBD15BI_MASK): New.
(BD24,BD24_MASK, C_LK, C_LK_MASK, C, C_MASK): New.
(IA16, IA16_MASK, I16A, I16A_MASK, I16L, I16L_MASK): New.
(IM7, IM7_MASK, LI20, LI20_MASK, SCI8, SCI8_MASK): New.
(SCI8BF, SCI8BF_MASK, SD4, SD4_MASK): New.
(SE_IM5, SE_IM5_MASK): New.
(SE_R, SE_R_MASK, SE_RR, SE_RR_MASK): New.
(EX, EX_MASK, BO16F, BO16T, BO32F, BO32T): New.
(BO32DNZ, BO32DZ): New.
(NO371, PPCSPE, PPCISEL, PPCEFS, MULHW): Include PPC_OPCODE_VLE.
(PPCVLE): New.
(powerpc_opcodes): Add new VLE instructions. Update existing
instruction to include PPCVLE if supported.
* ppc-dis.c (ppc_opts): Add vle entry.
(get_powerpc_dialect): New function.
(powerpc_init_dialect): VLE support.
(print_insn_big_powerpc): Call get_powerpc_dialect.
(print_insn_little_powerpc): Likewise.
(operand_value_powerpc): Handle negative shift counts.
(print_insn_powerpc): Handle 2-byte instruction lengths.
2012-05-14 19:45:30 +00:00
|
|
|
|
lang_add_section (&l->wild_statement.children, s, NULL, os);
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2008-10-20 12:14:29 +00:00
|
|
|
|
return os;
|
1999-05-03 07:29:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
2003-06-27 00:38:25 +00:00
|
|
|
|
gld_${EMULATION_NAME}_get_script (int *isfile)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
EOF
|
|
|
|
|
# Scripts compiled in.
|
|
|
|
|
# sed commands to quote an ld script as a C string.
|
1999-08-06 22:46:03 +00:00
|
|
|
|
sc="-f stringify.sed"
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2007-07-19 19:56:10 +00:00
|
|
|
|
fragment <<EOF
|
2001-09-03 07:29:50 +00:00
|
|
|
|
{
|
1999-05-03 07:29:11 +00:00
|
|
|
|
*isfile = 0;
|
|
|
|
|
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 12:51:03 +00:00
|
|
|
|
if (bfd_link_relocatable (&link_info) && config.build_constructors)
|
1999-05-03 07:29:11 +00:00
|
|
|
|
return
|
|
|
|
|
EOF
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 12:51:03 +00:00
|
|
|
|
echo ' ; else if (bfd_link_relocatable (&link_info)) return' >> e${EMULATION_NAME}.c
|
2002-11-30 08:39:46 +00:00
|
|
|
|
sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c
|
|
|
|
|
echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c
|
|
|
|
|
sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c
|
|
|
|
|
echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c
|
|
|
|
|
sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c
|
|
|
|
|
echo ' ; else return' >> e${EMULATION_NAME}.c
|
|
|
|
|
sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c
|
|
|
|
|
echo '; }' >> e${EMULATION_NAME}.c
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
2007-07-19 19:56:10 +00:00
|
|
|
|
fragment <<EOF
|
1999-05-03 07:29:11 +00:00
|
|
|
|
|
|
|
|
|
|
2001-09-03 07:29:50 +00:00
|
|
|
|
struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
|
1999-05-03 07:29:11 +00:00
|
|
|
|
{
|
|
|
|
|
gld_${EMULATION_NAME}_before_parse,
|
|
|
|
|
syslib_default,
|
|
|
|
|
hll_default,
|
|
|
|
|
after_parse_default,
|
|
|
|
|
gld_${EMULATION_NAME}_after_open,
|
|
|
|
|
after_allocation_default,
|
|
|
|
|
set_output_arch_default,
|
|
|
|
|
ldemul_default_target,
|
|
|
|
|
gld_${EMULATION_NAME}_before_allocation,
|
|
|
|
|
gld_${EMULATION_NAME}_get_script,
|
|
|
|
|
"${EMULATION_NAME}",
|
|
|
|
|
"${OUTPUT_FORMAT}",
|
2005-08-04 01:19:10 +00:00
|
|
|
|
finish_default,
|
1999-05-03 07:29:11 +00:00
|
|
|
|
NULL, /* create output section statements */
|
|
|
|
|
NULL, /* open dynamic archive */
|
|
|
|
|
gld${EMULATION_NAME}_place_orphan,
|
|
|
|
|
gld_${EMULATION_NAME}_set_symbols,
|
2003-02-28 01:32:31 +00:00
|
|
|
|
NULL, /* parse_args */
|
|
|
|
|
gld${EMULATION_NAME}_add_options,
|
|
|
|
|
gld${EMULATION_NAME}_handle_option,
|
2000-01-22 23:22:18 +00:00
|
|
|
|
NULL, /* unrecognized file */
|
|
|
|
|
NULL, /* list options */
|
2000-02-29 05:53:53 +00:00
|
|
|
|
NULL, /* recognized file */
|
2002-05-22 09:04:48 +00:00
|
|
|
|
NULL, /* find_potential_libraries */
|
2014-05-27 21:14:49 +00:00
|
|
|
|
NULL, /* new_vers_pattern */
|
|
|
|
|
NULL /* extra_map_file_text */
|
1999-05-03 07:29:11 +00:00
|
|
|
|
};
|
|
|
|
|
EOF
|