PATCH: Count size relocation as PC-relative relocation
H.J. Lu
hongjiu.lu@intel.com
Thu Jan 17 23:41:00 GMT 2013
More information about the Binutils mailing list
Thu Jan 17 23:41:00 GMT 2013
- Previous message (by thread): [PATCH 1/2 v4] ld: change --enable-new-dtags to only generate new dtags
- Next message (by thread): PATCH: Add 2 run-time tests for size relocation against hidden symbols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, For book keeping purpose, we can count size relocation as PC-relative relocation since it is position independent. I checked in this patch to do it. H.J. -- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index f75e046..30fead2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2013-01-17 H.J. Lu <hongjiu.lu@intel.com> + + * elf32-i386.c (elf_i386_check_relocs): Count size relocation as + PC-relative relocation. + * elf64-x86-64.c (elf_x86_64_check_relocs): Count size relocation + as PC-relative relocation. + 2013-01-16 H.J. Lu <hongjiu.lu@intel.com> * elf32-i386.c (elf_i386_check_relocs): Update R_386_SIZE32 diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 9c061ba..f8ad1d1 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1454,6 +1454,7 @@ elf_i386_check_relocs (bfd *abfd, struct elf_link_hash_entry *h; Elf_Internal_Sym *isym; const char *name; + bfd_boolean size_reloc; r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); @@ -1557,6 +1558,7 @@ elf_i386_check_relocs (bfd *abfd, break; case R_386_SIZE32: + size_reloc = TRUE; goto do_size; case R_386_TLS_IE_32: @@ -1706,6 +1708,7 @@ elf_i386_check_relocs (bfd *abfd, h->pointer_equality_needed = 1; } + size_reloc = FALSE; do_size: /* If we are creating a shared library, and this is a reloc against a global symbol, or a non PC relative reloc @@ -1803,7 +1806,8 @@ do_size: } p->count += 1; - if (r_type == R_386_PC32) + /* Count size relocation as PC-relative relocation. */ + if (r_type == R_386_PC32 || size_reloc) p->pc_count += 1; } break; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index c260606..79b6dc6 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1424,6 +1424,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, struct elf_link_hash_entry *h; Elf_Internal_Sym *isym; const char *name; + bfd_boolean size_reloc; r_symndx = htab->r_sym (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); @@ -1708,6 +1709,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_X86_64_SIZE32: case R_X86_64_SIZE64: + size_reloc = TRUE; goto do_size; case R_X86_64_32: @@ -1759,6 +1761,7 @@ pointer: h->pointer_equality_needed = 1; } + size_reloc = FALSE; do_size: /* If we are creating a shared library, and this is a reloc against a global symbol, or a non PC relative reloc @@ -1860,7 +1863,8 @@ do_size: } p->count += 1; - if (IS_X86_64_PCREL_TYPE (r_type)) + /* Count size relocation as PC-relative relocation. */ + if (IS_X86_64_PCREL_TYPE (r_type) || size_reloc) p->pc_count += 1; } break; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index c578fb6..2432df4 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2013-01-17 H.J. Lu <hongjiu.lu@intel.com> + + * ld-size/size32-3-i386.d: New file. + * ld-size/size32-3-x32.d: Likewise. + * ld-size/size32-3-x86-64.d: Likewise. + * ld-size/size32-3a.s: Likewise. + * ld-size/size32-3b.s: Likewise. + 2013-01-16 H.J. Lu <hongjiu.lu@intel.com> * ld-size/size.exp: New file. diff --git a/ld/testsuite/ld-size/size32-3-i386.d b/ld/testsuite/ld-size/size32-3-i386.d new file mode 100644 index 0000000..fbdd591 --- /dev/null +++ b/ld/testsuite/ld-size/size32-3-i386.d @@ -0,0 +1,11 @@ +#source: size32-3a.s +#source: size32-3b.s +#as: --32 +#ld: -shared -melf_i386 -z nocombreloc +#readelf: -r --wide +#target: x86_64-*-* i?86-*-* + +#failif +#... +.* +R_386_NONE +.* +#... diff --git a/ld/testsuite/ld-size/size32-3-x32.d b/ld/testsuite/ld-size/size32-3-x32.d new file mode 100644 index 0000000..794ac16 --- /dev/null +++ b/ld/testsuite/ld-size/size32-3-x32.d @@ -0,0 +1,11 @@ +#source: size32-3a.s +#source: size32-3b.s +#as: --x32 +#ld: -shared -melf32_x86_64 -z nocombreloc +#readelf: -r --wide +#target: x86_64-*-* + +#failif +#... +.* +R_X86_64_NONE +.* +#... diff --git a/ld/testsuite/ld-size/size32-3-x86-64.d b/ld/testsuite/ld-size/size32-3-x86-64.d new file mode 100644 index 0000000..e8c083a --- /dev/null +++ b/ld/testsuite/ld-size/size32-3-x86-64.d @@ -0,0 +1,11 @@ +#source: size32-3a.s +#source: size32-3b.s +#as: --64 +#ld: -shared -melf_x86_64 -z nocombreloc +#readelf: -r --wide +#target: x86_64-*-* + +#failif +#... +.* +R_X86_64_NONE +.* +#... diff --git a/ld/testsuite/ld-size/size32-3a.s b/ld/testsuite/ld-size/size32-3a.s new file mode 100644 index 0000000..bb21345 --- /dev/null +++ b/ld/testsuite/ld-size/size32-3a.s @@ -0,0 +1,5 @@ +# 32-bit size relocation against hidden symbol in shared object + .comm xxx,40,32 + .data + .p2align 2 + .long xxx@SIZE diff --git a/ld/testsuite/ld-size/size32-3b.s b/ld/testsuite/ld-size/size32-3b.s new file mode 100644 index 0000000..32bd543 --- /dev/null +++ b/ld/testsuite/ld-size/size32-3b.s @@ -0,0 +1,2 @@ +# 32-bit size relocation against hidden symbol in shared object + .hidden xxx
- Previous message (by thread): [PATCH 1/2 v4] ld: change --enable-new-dtags to only generate new dtags
- Next message (by thread): PATCH: Add 2 run-time tests for size relocation against hidden symbols
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list