This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Support -z combreloc in binutils


Hi Jakub,

> This patch adds support for ld -z combreloc, which instead of
> creating usual zillions of .rel* resp. .rela* sections just creates
> one big (in addition to .rel.plt/.rela.plt or PLT-like rela section)
> .rel.dyn resp. .rela.dyn section with all dynamic relocations.

> 2001-08-15  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* elf-bfd.h (enum elf_reloc_type_class): New.
> 	(struct elf_backend_data): Add elf_backend_reloc_type_class.
> 	(_bfd_elf_reloc_type_class): New.
> 	* elfxx-target.h (elf_backend_reloc_type_class): Define.
> 	(elfNN_bed): Add elf_backend_reloc_type_class.
> 	* elf.c (_bfd_elf_reloc_type_class): New.
> 	* elf32-i386.c (elf_i386_reloc_type_class): New.
> 	(elf_backend_reloc_type_class): Define.
> 	* elflink.h (size_dynamic_sections): Add spare DT_NULL tags.
> 	(struct elf_link_sort_rela): New.
> 	(elf_link_sort_cmp1, elf_link_sort_cmp2, elf_link_sort_relocs): New.
> 	(elf_bfd_final_link): Call elf_link_sort_relocs.
> 	Convert one spare DT_NULL into DT_RELCOUNT resp. DT_RELACOUNT if
> 	necessary.
> 
> 	* bfdlink.h (struct bfd_link_info): Add combreloc and
> 	spare_dynamic_tags fields.
> 
> 	* emultempl/elf32.em (place_orphan): Place orphan .rel* sections
> 	into .rel.dyn resp. .rela.dyn if combreloc.
> 	(get_script): If .x linker script is equal to .xn, only put it
> 	once into the binary.
> 	Add .xc and .xsc scripts.
> 	(parse_args): Handle -z combreloc and -z nocombreloc.
> 	* scripttempl/elf.sc (.rela.sbss): Fix a typo.
> 	For .xc and .xsc scripts put all .rel* or .rela* input sections
> 	but .rel*.plt and PLT-like sections into .rel.dyn resp. .rela.dyn.
> 	* genscripts.sh (GENERATE_COMBRELOC_SCRIPT): Set if SCRIPT_NAME
> 	is elf.
> 	Strip trailing whitespace from script.
> 	Generate .xc and .xsc scripts if requested.
> 	* ldmain.c (main): Initialize link_info.combreloc and
> 	link_info.spare_dynamic_tags.
> 	* lexsup.c (OPTION_SPARE_DYNAMIC_TAGS): Define.
> 	(ld_options): Add --spare-dynamic-tags option.
> 	(parse_args): Likewise.

Approved.  Please apply this patch, but if possible, please also make
the following minor formatting changes:

> +enum elf_reloc_type_class
> +{
> +  reloc_class_normal,
> +  reloc_class_relative,
> +  reloc_class_plt,
> +  reloc_class_copy
> +};

This violates the GNU coding standard.  Either indent the curly braces
so that they are not in column one (my preferred solution) or move the
opening curly brace to the end of the previous line (the more common
solution).

> +struct elf_link_sort_rela
> +{
> +  bfd_vma offset;
> +  enum elf_reloc_type_class type;
> +  union
> +    {
> +      Elf_Internal_Rel rel;
> +      Elf_Internal_Rela rela;
> +    } u;
> +};

Ditto.

> +  /* true if non-PLT relocs should be merged into one reloc section
> +     and sorted so that relocs against the same symbol come together.  */
> +  boolean combreloc;

Despite the example in the comment before this one, I believe that
this sentence should start with a capital letter.


Also - please could you an entry to ld.texinfo documenting the new
command line switch, an entry to ldint.texinfo describing the new .xc
file and an entry to NEWS describing the new linker feature.

Cheers
        Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]