Apply patch from Richard Gorton <gorton@scrugs.lkg.dec.com> to implement

--emit-relocs switch to the linker to preserve relocs in an output executable
This commit is contained in:
Nick Clifton 2000-05-17 19:38:53 +00:00
parent f4bd37dad4
commit a712da2085
9 changed files with 60 additions and 14 deletions

View file

@ -1,3 +1,13 @@
2000-05-17 S. Bharadwaj Yadavalli <sby@scrugs.lkg.dec.com>
Rick Gorton <gorton@scrugs.lkg.dec.com>
* elflink.h: Add emitrelocations support: when enabled, relocation
information and relocation sections are put into final output
executables. If the emitrelocations flag is set, do the following:
(elf_bfd_final_link): Emit relocation sections.
(elf_link_input_bfd): Compute relocation section contents.
(elf_gc_sections): Don't clean relocation sections.
2000-05-16 Catherine Moore <clm@cygnux.com>
* som.c (som_decode_symclass): Recognize weak symbols.
@ -1246,7 +1256,7 @@ Thu Feb 10 20:07:50 GMT 2000 Toshiyasu Morita (toshi.morita@sega.com)
2000-02-08 Mark Elbrecht <snowball3@bigfoot.com>
* coff-go32.c: Update comment. Update copyright.
2000-01-27 Thomas de Lellis <tdel@windriver.com>
* syms.c (bfd_decode_symclass)
@ -2603,8 +2613,8 @@ Mon Jul 19 14:03:44 1999 Mark P. Mitchell <mark@codesourcery.com>
* coffcode.h (CREATE_BIG_COFF_TARGET_VEC): New macro.
(CREATE_LITTLE_COFF_TARGET_VEC): New macro.
* aix386-core.c: Initialise new field of bfd_target structure.
* aout-adobe.c: Initialise new field of bfd_target structure.
* aix386-core.c: Initialise new field of bfd_target structure.
* aout-adobe.c: Initialise new field of bfd_target structure.
* aout-arm.c: Initialise new field of bfd_target structure.
* aout-target.h: Initialise new field of bfd_target structure.
* aout-tic30.c: Initialise new field of bfd_target structure.

View file

@ -357,7 +357,6 @@ elf_link_add_archive_symbols (abfd, info)
}
/* We need to include this archive member. */
element = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
if (element == (bfd *) NULL)
goto error_return;
@ -4104,7 +4103,7 @@ elf_bfd_final_link (abfd, info)
the linker has decided to not include. */
sec->linker_mark = true;
if (info->relocateable)
if (info->relocateable || info->emitrelocations)
o->reloc_count += sec->reloc_count;
if (sec->_raw_size > max_contents_size)
@ -4172,7 +4171,7 @@ elf_bfd_final_link (abfd, info)
/* Figure out how many relocations we will have in each section.
Just using RELOC_COUNT isn't good enough since that doesn't
maintain a separate value for REL vs. RELA relocations. */
if (info->relocateable)
if (info->relocateable || info->emitrelocations)
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
for (o = sub->sections; o != NULL; o = o->next)
{
@ -4280,7 +4279,7 @@ elf_bfd_final_link (abfd, info)
/* Start writing out the symbol table. The first symbol is always a
dummy symbol. */
if (info->strip != strip_all || info->relocateable)
if (info->strip != strip_all || info->relocateable || info->emitrelocations)
{
elfsym.st_value = 0;
elfsym.st_size = 0;
@ -4313,7 +4312,7 @@ elf_bfd_final_link (abfd, info)
symbols have no names. We store the index of each one in the
index field of the section, so that we can find it again when
outputting relocs. */
if (info->strip != strip_all || info->relocateable)
if (info->strip != strip_all || info->relocateable || info->emitrelocations)
{
elfsym.st_size = 0;
elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
@ -4324,7 +4323,7 @@ elf_bfd_final_link (abfd, info)
if (o != NULL)
o->target_index = bfd_get_symcount (abfd);
elfsym.st_shndx = i;
if (info->relocateable || o == NULL)
if (info->relocateable || info->emitrelocations || o == NULL)
elfsym.st_value = 0;
else
elfsym.st_value = o->vma;
@ -5492,7 +5491,7 @@ elf_link_input_bfd (finfo, input_bfd)
finfo->sections))
return false;
if (finfo->info->relocateable)
if (finfo->info->relocateable || finfo->info->emitrelocations)
{
Elf_Internal_Rela *irela;
Elf_Internal_Rela *irelaend;

View file

@ -1,3 +1,8 @@
2000-05-17 S. Bharadwaj Yadavalli <sby@scrugs.lkg.dec.com>
Rick Gorton <gorton@scrugs.lkg.dec.com>
* bfdlink.h (struct bfd_link_info): Add emitrelocations flag.
2000-05-08 Alan Modra <alan@linuxcare.com.au>
* dis-asm.h (print_insn_tic54x): Declare.
@ -269,7 +274,7 @@ Mon Feb 1 21:05:46 1999 Catherine Moore <clm@cygnus.com>
* dis-asm.h (print_insn_i386_att): Declare.
(print_insn_i386_intel): Declare.
998-12-30 Michael Meissner <meissner@cygnus.com>
1998-12-30 Michael Meissner <meissner@cygnus.com>
* dis-asm.h (INIT_DISASSEMBLE_INFO_NO_ARCH): Cast STREAM and
FPRINTF_FUNC to avoid compiler warnings.
@ -299,8 +304,7 @@ Tue Dec 8 00:30:31 1998 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
(demangling_styles): add new edg_demangling style
(EDG_DEMANGLING_STYLE_STRING): new macro
(EDG_DEMANGLING): new macro
* demangle.h (DMGL_HP): new macro, for HP/aCC compiler.
(DMGL_HP): new macro, for HP/aCC compiler.
(DMGL_STYLE_MASK): modify to include new HP's style.
(demangling_styles): add new hp_demangling value.
(HP_DEMANGLING_STYLE_STRING): new macro.

View file

@ -179,6 +179,8 @@ struct bfd_link_info
const struct bfd_link_callbacks *callbacks;
/* true if BFD should generate a relocateable object file. */
boolean relocateable;
/* true if BFD should generate relocation information in the final executable. */
boolean emitrelocations;
/* true if BFD should generate a "task linked" object file,
similar to relocatable but also with globals converted to statics. */
boolean task_link;

View file

@ -1,3 +1,12 @@
2000-05-17 S. Bharadwaj Yadavalli <sby@scrugs.lkg.dec.com>
Rick Gorton <gorton@scrugs.lkg.dec.com>
Add support for '-q' == '--emit-relocs' switch.
* ldmain.c (main): Default to false.
* lexsup.c (parse_args): Turn on emitrelocations flag if set.
* NEWS: Describe the emitrelocations switch.
* ld.texinfo: Describe the emitrelocations switch.
2000-05-16 Charles Wilson <cwilson@ece.gatech.edu>
* ld/emultempl/pe.em (_open_dynamic_archive): New function: Search

View file

@ -2,6 +2,12 @@
Changes in version 2.10:
* Added ability to emit full relocation information in linked executables,
enabled by --emit-relocs. Some post-linkage optimization tools need
this information in order to be able to correctly identify and perform
symbol relative addressing in the event of changes in section contents
(instructions being added or deleted, extending data sections, etc.)
* Added AT> to the linker script language to allow load-time allocation of
sections into regions.

View file

@ -588,6 +588,16 @@ If @var{level} is a numeric values greater than zero @code{ld} optimizes
the output. This might take significantly longer and therefore probably
should only be enabled for the final binary.
@kindex -q
@kindex --emit-relocs
@cindex retain relocations in final executable
@item -q
@itemx --emit-relocs
Leave relocation sections and contents in fully linked exececutables.
Post link analysis and optimization tools may need this information in
order to perform correct modifications of executables. This results
in larger executables.
@cindex partial link
@cindex relocatable output
@kindex -r

View file

@ -214,6 +214,7 @@ main (argc, argv)
link_info.callbacks = &link_callbacks;
link_info.relocateable = false;
link_info.emitrelocations = false;
link_info.shared = false;
link_info.symbolic = false;
link_info.static_link = false;
@ -1150,7 +1151,7 @@ undefined_symbol (info, name, abfd, section, address, fatal)
bfd *abfd;
asection *section;
bfd_vma address;
boolean fatal;
boolean fatal ATTRIBUTE_UNUSED;
{
static char *error_name;
static unsigned int error_count;

View file

@ -205,6 +205,8 @@ static const struct ld_option ld_options[] =
'\0', NULL, N_("Ignored for SVR4 compatibility"), ONE_DASH },
{ {"relocateable", no_argument, NULL, 'r'},
'r', NULL, N_("Generate relocateable output"), TWO_DASHES },
{ {"emit-relocs", no_argument, NULL, 'q'},
'q', NULL, "Generate relocations in final output", TWO_DASHES },
{ {NULL, no_argument, NULL, '\0'},
'i', NULL, NULL, ONE_DASH },
{ {"just-symbols", required_argument, NULL, 'R'},
@ -717,6 +719,9 @@ parse_args (argc, argv)
lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
break;
case 'i':
case 'q':
link_info.emitrelocations = true;
break;
case 'r':
link_info.relocateable = true;
config.build_constructors = false;