This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: DT_GNU_HASH latest patches
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: jakub at redhat dot com
- Cc: binutils at sources dot redhat dot com
- Date: Tue, 11 Jul 2006 15:35:01 +0200
- Subject: Re: DT_GNU_HASH latest patches
> Date: Mon, 10 Jul 2006 23:51:35 +0200
> From: Jakub Jelinek <jakub@redhat.com>
> 2006-07-10 Jakub Jelinek <jakub@redhat.com>
>
> include/
> * bfdlink.h (struct bfd_link_info): Add emit_hash and
> emit_gnu_hash bitfields.
> include/elf/
> * common.h (SHT_GNU_HASH, DT_GNU_HASH): Define.
> ld/
> * scripttempl/elf.sc: Add .gnu.hash section.
> * emultempl/elf32.em (OPTION_HASH_STYLE): Define.
> (gld${EMULATION_NAME}_add_options): Register --hash-style option.
> (gld${EMULATION_NAME}_handle_option): Handle it.
> (gld${EMULATION_NAME}_list_options): Document it.
> * ldmain.c (main): Initialize emit_hash and emit_gnu_hash.
> * ld.texinfo: Document --hash-style option.
> ld/testsuite/
> * ld-powerpc/tlsso32.r: Adjust.
> * ld-powerpc/tlsso32.d: Adjust.
> * ld-powerpc/tlsso32.g: Adjust.
> * ld-powerpc/tlsso.r: Adjust.
> * ld-powerpc/tlsso.g: Adjust.
> * ld-powerpc/tlstocso.g: Adjust.
> bfd/
> * elf.c (_bfd_elf_print_private_bfd_data): Handle DT_GNU_HASH.
> (bfd_section_from_shdr, elf_fake_sections, assign_section_numbers):
> Handle SHT_GNU_HASH.
> (special_sections_g): Include .gnu.hash section.
> (bfd_elf_gnu_hash): New function.
> * elf-bfd.h (bfd_elf_gnu_hash, _bfd_elf_hash_symbol): New prototypes.
> (struct elf_backend_data): Add elf_hash_symbol method.
> * elflink.c (_bfd_elf_link_create_dynamic_sections): Create .hash
> only if info->emit_hash, create .gnu.hash section if
> info->emit_gnu_hash.
> (struct collect_gnu_hash_codes): New type.
> (elf_collect_gnu_hash_codes, elf_renumber_gnu_hash_syms,
> _bfd_elf_hash_symbol): New functions.
> (compute_bucket_count): Don't compute HASHCODES array, instead add
> that and NSYMS as arguments. Use bed->s->sizeof_hash_entry
> instead of bed->s->arch_size / 8. Fix .hash size estimation.
> When not optimizing, use the number of hashed symbols rather than
> dynsymcount.
> (bfd_elf_size_dynamic_sections): Only add DT_HASH if info->emit_hash,
> and ADD DT_GNU_HASH if info->emit_gnu_hash.
> (bfd_elf_size_dynsym_hash_dynstr): Size .hash only if info->emit_hash,
> adjust compute_bucket_count caller. Create and populate .gnu.hash
> section if info->emit_gnu_hash.
> (elf_link_output_extsym): Only populate .hash section if
> finfo->hash_sec != NULL.
> (bfd_elf_final_link): Adjust assertion. Handle DT_GNU_HASH.
> * elfxx-target.h (elf_backend_hash_symbol): Define if not yet defined.
> (elfNN_bed): Add elf_backend_hash_symbol.
> * elf64-x86-64.c (elf64_x86_64_hash_symbol): New function.
> (elf_backend_hash_symbol): Define.
> * elf32-i386.c (elf_i386_hash_symbol): New function.
> (elf_backend_hash_symbol): Define.
> binutils/
> * readelf.c (get_dynamic_type): Handle DT_GNU_HASH.
> (get_section_type_name): Handle SHT_GNU_HASH.
> (dynamic_info_DT_GNU_HASH): New variable.
> (process_dynamic_section): Handle DT_GNU_HASH.
> (process_symbol_table): Print also DT_GNU_HASH histogram.
Great, great. Though, one of these bits caused, for
--target=cris-axis-elf:
FAIL: ld-cris/libdso-2
Looks like you forgot to adjust ld/testsuite/ld-cris/libdso-2.d.
Is it to be expected that one of your changes (presumably in
compute_bucket_count) caused some hash-related section in a DSO
to shrink by eight bytes, despite no change in section types (no
.gnu.hash)? I see you made some similar adjustments for the
powerpc TLS tests, but thought I'd better check as this
secondary effect on non-.gnu.hash objects wasn't clearly enough
announced as intended.
If it was intended, and not a sign of a bug, a proper testsuite
adjustment could have looked like this: ;)
(will check in when clarified)
* ld-cris/libdso-2.d: Adjust for recent hash-related changes.
Index: libdso-2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/libdso-2.d,v
retrieving revision 1.13
diff -u -p -r1.13 libdso-2.d
--- libdso-2.d 2 Jun 2006 00:31:59 -0000 1.13
+++ libdso-2.d 11 Jul 2006 13:19:27 -0000
@@ -27,14 +27,14 @@ There are 13 section headers.*
#...
Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
#...
-00002200 0000000c R_CRIS_RELATIVE 00000158
+00002[12][0-9a-f][048c] 0000000c R_CRIS_RELATIVE 00000150
#...
Symbol table '\.dynsym' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0+ 0 NOTYPE LOCAL DEFAULT UND
1: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 7
2: 0+ 0 OBJECT GLOBAL DEFAULT ABS TST1
- 3: 0+15c 0 FUNC GLOBAL DEFAULT 7 export_1@@TST1
+ 3: 0+154 0 FUNC GLOBAL DEFAULT 7 export_1@@TST1
Symbol table '\.symtab' contains 18 entries:
Num: Value Size Type Bind Vis Ndx Name
@@ -48,11 +48,11 @@ Symbol table '\.symtab' contains 18 entr
7: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 7
8: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 8
9: [0-9a-f]+ 0 SECTION LOCAL DEFAULT 9
- 10: 0+216c 0 OBJECT LOCAL HIDDEN ABS _DYNAMIC
- 11: 0+2204 0 NOTYPE LOCAL DEFAULT ABS __bss_start
- 12: 0+2204 0 NOTYPE LOCAL DEFAULT ABS _edata
- 13: 0+21f4 0 OBJECT LOCAL HIDDEN ABS _GLOBAL_OFFSET_TABLE_
- 14: 0+2220 0 NOTYPE LOCAL DEFAULT ABS _end
- 15: 0+158 0 FUNC LOCAL DEFAULT 7 dsofn
+ 10: 0+2..[046c] 0 OBJECT LOCAL HIDDEN ABS _DYNAMIC
+ 11: 0+2..[046c] 0 NOTYPE LOCAL DEFAULT ABS __bss_start
+ 12: 0+2..[046c] 0 NOTYPE LOCAL DEFAULT ABS _edata
+ 13: 0+2..[046c] 0 OBJECT LOCAL HIDDEN ABS _GLOBAL_OFFSET_TABLE_
+ 14: 0+2..[046c] 0 NOTYPE LOCAL DEFAULT ABS _end
+ 15: 0+150 0 FUNC LOCAL DEFAULT 7 dsofn
16: 0+ 0 OBJECT GLOBAL DEFAULT ABS TST1
- 17: 0+15c 0 FUNC GLOBAL DEFAULT 7 export_1
+ 17: 0+154 0 FUNC GLOBAL DEFAULT 7 export_1
brgds, H-P