* ldlang.c (lang_size_sections): If _cooked_size is not 0, then

don't clobber it when not relaxing.

	* ld.h (ld_config_type): Remove traditional_format field.
	* ldmain.c (main): Use link_info.traditional_format rather than
	config.traditional_format.
	* ldlang.c (ldlang_open_output): Likewise.
	* lexsup.c (parse_args): Likewise.
	* emultempl/aix.em (gld${EMULATION_NAME}_parse_args): Likewise.
	* mpw-eppcmac.c (gldppcmacos_parse_args): Likewise.
This commit is contained in:
Ian Lance Taylor 1996-04-22 21:32:58 +00:00
parent af50cd9170
commit 6799c638e5
6 changed files with 62 additions and 14 deletions

View File

@ -1,5 +1,16 @@
Mon Apr 22 12:07:32 1996 Ian Lance Taylor <ian@cygnus.com> Mon Apr 22 12:07:32 1996 Ian Lance Taylor <ian@cygnus.com>
* ldlang.c (lang_size_sections): If _cooked_size is not 0, then
don't clobber it when not relaxing.
* ld.h (ld_config_type): Remove traditional_format field.
* ldmain.c (main): Use link_info.traditional_format rather than
config.traditional_format.
* ldlang.c (ldlang_open_output): Likewise.
* lexsup.c (parse_args): Likewise.
* emultempl/aix.em (gld${EMULATION_NAME}_parse_args): Likewise.
* mpw-eppcmac.c (gldppcmacos_parse_args): Likewise.
* ldlang.c (wild_doit): Discard debugging sections if we are * ldlang.c (wild_doit): Discard debugging sections if we are
stripping debugging information. stripping debugging information.

31
ld/ld.h
View File

@ -1,6 +1,6 @@
/* ld.h - /* ld.h -
Copyright (C) 1991, 1993 Free Software Foundation, Inc. Copyright (C) 1991, 1993, 1994, 1995 Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker. This file is part of GLD, the Gnu Linker.
@ -21,6 +21,17 @@
#ifndef LD_H #ifndef LD_H
#define LD_H #define LD_H
/* Look in this environment name for the linker to pretend to be */
#define EMULATION_ENVIRON "LDEMULATION"
/* If in there look for the strings: */
/* Look in this variable for a target format */
#define TARGET_ENVIRON "GNUTARGET"
/* Input sections which are put in a section of this name are actually
discarded. */
#define DISCARD_SECTION_NAME "/DISCARD/"
/* Extra information we hold on sections */ /* Extra information we hold on sections */
typedef struct user_section_struct typedef struct user_section_struct
{ {
@ -59,6 +70,10 @@ typedef struct
/* Runtime library search path from the -rpath argument. */ /* Runtime library search path from the -rpath argument. */
char *rpath; char *rpath;
/* Link time runtime library search path from the -rpath-link
argument. */
char *rpath_link;
/* Big or little endian as set on command line. */ /* Big or little endian as set on command line. */
enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE } endian; enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE } endian;
@ -81,20 +96,25 @@ typedef struct
boolean magic_demand_paged; boolean magic_demand_paged;
boolean make_executable; boolean make_executable;
/* If true, request BFD to use the traditional format. */
boolean traditional_format;
/* If true, doing a dynamic link. */ /* If true, doing a dynamic link. */
boolean dynamic_link; boolean dynamic_link;
/* If true, build constructors. */
boolean build_constructors; boolean build_constructors;
/* If true, warn about any constructors. */
boolean warn_constructors;
/* If true, warn about merging common symbols with others. */ /* If true, warn about merging common symbols with others. */
boolean warn_common; boolean warn_common;
/* If true, only warn once about a particular undefined symbol. */ /* If true, only warn once about a particular undefined symbol. */
boolean warn_once; boolean warn_once;
/* If true, warn if multiple global-pointers are needed (Alpha
only). */
boolean warn_multiple_gp;
boolean sort_common; boolean sort_common;
boolean text_read_only; boolean text_read_only;
@ -120,6 +140,9 @@ typedef enum
extern boolean had_script; extern boolean had_script;
extern boolean force_make_executable; extern boolean force_make_executable;
/* Non-zero if we are processing a --defsym from the command line. */
extern int parsing_defsym;
extern int yyparse PARAMS ((void)); extern int yyparse PARAMS ((void));
#endif #endif

View File

@ -1110,7 +1110,7 @@ ldlang_open_output (statement)
output_bfd->flags |= WP_TEXT; output_bfd->flags |= WP_TEXT;
else else
output_bfd->flags &= ~WP_TEXT; output_bfd->flags &= ~WP_TEXT;
if (config.traditional_format) if (link_info.traditional_format)
output_bfd->flags |= BFD_TRADITIONAL_FORMAT; output_bfd->flags |= BFD_TRADITIONAL_FORMAT;
else else
output_bfd->flags &= ~BFD_TRADITIONAL_FORMAT; output_bfd->flags &= ~BFD_TRADITIONAL_FORMAT;
@ -2139,7 +2139,10 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
i = (*prev)->input_section.section; i = (*prev)->input_section.section;
if (! relax) if (! relax)
i->_cooked_size = i->_raw_size; {
if (i->_cooked_size == 0)
i->_cooked_size = i->_raw_size;
}
else else
{ {
boolean again; boolean again;

View File

@ -169,7 +169,6 @@ main (argc, argv)
/* Initialize the data about options. */ /* Initialize the data about options. */
trace_files = trace_file_tries = version_printed = false; trace_files = trace_file_tries = version_printed = false;
whole_archive = false; whole_archive = false;
config.traditional_format = false;
config.build_constructors = true; config.build_constructors = true;
config.dynamic_link = false; config.dynamic_link = false;
command_line.force_common_definition = false; command_line.force_common_definition = false;
@ -181,6 +180,7 @@ main (argc, argv)
link_info.shared = false; link_info.shared = false;
link_info.symbolic = false; link_info.symbolic = false;
link_info.static_link = false; link_info.static_link = false;
link_info.traditional_format = false;
link_info.strip = strip_none; link_info.strip = strip_none;
link_info.discard = discard_none; link_info.discard = discard_none;
link_info.lprefix_len = 1; link_info.lprefix_len = 1;
@ -660,6 +660,17 @@ multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
asection *nsec; asection *nsec;
bfd_vma nval; bfd_vma nval;
{ {
/* If either section has the output_section field set to
bfd_abs_section_ptr, it means that the section is being
discarded, and this is not really a multiple definition at all.
FIXME: It would be cleaner to somehow ignore symbols defined in
sections which are being discarded. */
if ((osec->output_section != NULL
&& bfd_is_abs_section (osec->output_section))
|| (nsec->output_section != NULL
&& bfd_is_abs_section (nsec->output_section)))
return true;
einfo ("%X%C: multiple definition of `%T'\n", einfo ("%X%C: multiple definition of `%T'\n",
nbfd, nsec, nval, name); nbfd, nsec, nval, name);
if (obfd != (bfd *) NULL) if (obfd != (bfd *) NULL)

View File

@ -141,11 +141,11 @@ static const struct ld_option ld_options[] =
'E', NULL, "Export all dynamic symbols", TWO_DASHES }, 'E', NULL, "Export all dynamic symbols", TWO_DASHES },
{ {NULL, optional_argument, NULL, '\0'}, { {NULL, optional_argument, NULL, '\0'},
'F', "[FORMAT]", "Ignored", ONE_DASH }, 'F', "[FORMAT]", "Ignored", ONE_DASH },
{ {NULL, no_argument, NULL, '\0'},
'g', NULL, "Ignored", ONE_DASH },
{ {"gpsize", required_argument, NULL, 'G'}, { {"gpsize", required_argument, NULL, 'G'},
'G', "SIZE", "Small data size (if no size, same as --shared)", 'G', "SIZE", "Small data size (if no size, same as --shared)",
TWO_DASHES }, TWO_DASHES },
{ {NULL, no_argument, NULL, '\0'},
'g', NULL, "Ignored", ONE_DASH },
{ {"soname", required_argument, NULL, OPTION_SONAME}, { {"soname", required_argument, NULL, OPTION_SONAME},
'h', "FILENAME", "Set internal name of shared library", ONE_DASH }, 'h', "FILENAME", "Set internal name of shared library", ONE_DASH },
{ {"library", required_argument, NULL, 'l'}, { {"library", required_argument, NULL, 'l'},
@ -204,10 +204,10 @@ static const struct ld_option ld_options[] =
'\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH }, '\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH },
{ {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED}, { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
'\0', NULL, "Link against shared libraries", ONE_DASH }, '\0', NULL, "Link against shared libraries", ONE_DASH },
{ {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
'\0', NULL, NULL, ONE_DASH },
{ {"dy", no_argument, NULL, OPTION_CALL_SHARED}, { {"dy", no_argument, NULL, OPTION_CALL_SHARED},
'\0', NULL, NULL, ONE_DASH }, '\0', NULL, NULL, ONE_DASH },
{ {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
'\0', NULL, NULL, ONE_DASH },
{ {"Bstatic", no_argument, NULL, OPTION_NON_SHARED}, { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
'\0', NULL, "Do not link against shared libraries", ONE_DASH }, '\0', NULL, "Do not link against shared libraries", ONE_DASH },
{ {"dn", no_argument, NULL, OPTION_NON_SHARED}, { {"dn", no_argument, NULL, OPTION_NON_SHARED},
@ -630,7 +630,7 @@ parse_args (argc, argv)
set_section_start (".text", optarg); set_section_start (".text", optarg);
break; break;
case OPTION_TRADITIONAL_FORMAT: case OPTION_TRADITIONAL_FORMAT:
config.traditional_format = true; link_info.traditional_format = true;
break; break;
case OPTION_UR: case OPTION_UR:
link_info.relocateable = true; link_info.relocateable = true;

View File

@ -335,7 +335,7 @@ gldppcmacos_parse_args (argc, argv)
break; break;
case OPTION_NOSTRCMPCT: case OPTION_NOSTRCMPCT:
config.traditional_format = true; link_info.traditional_format = true;
break; break;
case OPTION_PD: case OPTION_PD:
@ -384,7 +384,7 @@ gldppcmacos_parse_args (argc, argv)
break; break;
case OPTION_STRCMPCT: case OPTION_STRCMPCT:
config.traditional_format = false; link_info.traditional_format = false;
break; break;
case OPTION_UNIX: case OPTION_UNIX: