elf64-s390.c (99461) | elf64-s390.c (107492) |
---|---|
1/* IBM S/390-specific support for 64-bit ELF 2 Copyright 2000, 2001, 2002 Free Software Foundation, Inc. 3 Contributed Martin Schwidefsky (schwidefsky@de.ibm.com). 4 5 This file is part of BFD, the Binary File Descriptor library. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by --- 26 unchanged lines hidden (view full) --- 35 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 36static struct bfd_link_hash_table *elf_s390_link_hash_table_create 37 PARAMS ((bfd *)); 38static boolean create_got_section 39 PARAMS((bfd *, struct bfd_link_info *)); 40static boolean elf_s390_create_dynamic_sections 41 PARAMS((bfd *, struct bfd_link_info *)); 42static void elf_s390_copy_indirect_symbol | 1/* IBM S/390-specific support for 64-bit ELF 2 Copyright 2000, 2001, 2002 Free Software Foundation, Inc. 3 Contributed Martin Schwidefsky (schwidefsky@de.ibm.com). 4 5 This file is part of BFD, the Binary File Descriptor library. 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by --- 26 unchanged lines hidden (view full) --- 35 PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); 36static struct bfd_link_hash_table *elf_s390_link_hash_table_create 37 PARAMS ((bfd *)); 38static boolean create_got_section 39 PARAMS((bfd *, struct bfd_link_info *)); 40static boolean elf_s390_create_dynamic_sections 41 PARAMS((bfd *, struct bfd_link_info *)); 42static void elf_s390_copy_indirect_symbol |
43 PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); | 43 PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *, 44 struct elf_link_hash_entry *)); |
44static boolean elf_s390_check_relocs 45 PARAMS ((bfd *, struct bfd_link_info *, asection *, 46 const Elf_Internal_Rela *)); 47static asection *elf_s390_gc_mark_hook | 45static boolean elf_s390_check_relocs 46 PARAMS ((bfd *, struct bfd_link_info *, asection *, 47 const Elf_Internal_Rela *)); 48static asection *elf_s390_gc_mark_hook |
48 PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, | 49 PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
49 struct elf_link_hash_entry *, Elf_Internal_Sym *)); 50static boolean elf_s390_gc_sweep_hook 51 PARAMS ((bfd *, struct bfd_link_info *, asection *, 52 const Elf_Internal_Rela *)); 53static boolean elf_s390_adjust_dynamic_symbol 54 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 55static boolean allocate_dynrelocs 56 PARAMS ((struct elf_link_hash_entry *, PTR)); --- 362 unchanged lines hidden (view full) --- 419 420static struct bfd_link_hash_table * 421elf_s390_link_hash_table_create (abfd) 422 bfd *abfd; 423{ 424 struct elf_s390_link_hash_table *ret; 425 bfd_size_type amt = sizeof (struct elf_s390_link_hash_table); 426 | 50 struct elf_link_hash_entry *, Elf_Internal_Sym *)); 51static boolean elf_s390_gc_sweep_hook 52 PARAMS ((bfd *, struct bfd_link_info *, asection *, 53 const Elf_Internal_Rela *)); 54static boolean elf_s390_adjust_dynamic_symbol 55 PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); 56static boolean allocate_dynrelocs 57 PARAMS ((struct elf_link_hash_entry *, PTR)); --- 362 unchanged lines hidden (view full) --- 420 421static struct bfd_link_hash_table * 422elf_s390_link_hash_table_create (abfd) 423 bfd *abfd; 424{ 425 struct elf_s390_link_hash_table *ret; 426 bfd_size_type amt = sizeof (struct elf_s390_link_hash_table); 427 |
427 ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt); | 428 ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt); |
428 if (ret == NULL) 429 return NULL; 430 431 if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) 432 { | 429 if (ret == NULL) 430 return NULL; 431 432 if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) 433 { |
433 bfd_release (abfd, ret); | 434 free (ret); |
434 return NULL; 435 } 436 437 ret->sgot = NULL; 438 ret->sgotplt = NULL; 439 ret->srelgot = NULL; 440 ret->splt = NULL; 441 ret->srelplt = NULL; --- 24 unchanged lines hidden (view full) --- 466 abort (); 467 468 htab->srelgot = bfd_make_section (dynobj, ".rela.got"); 469 if (htab->srelgot == NULL 470 || ! bfd_set_section_flags (dynobj, htab->srelgot, 471 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 472 | SEC_IN_MEMORY | SEC_LINKER_CREATED 473 | SEC_READONLY)) | 435 return NULL; 436 } 437 438 ret->sgot = NULL; 439 ret->sgotplt = NULL; 440 ret->srelgot = NULL; 441 ret->splt = NULL; 442 ret->srelplt = NULL; --- 24 unchanged lines hidden (view full) --- 467 abort (); 468 469 htab->srelgot = bfd_make_section (dynobj, ".rela.got"); 470 if (htab->srelgot == NULL 471 || ! bfd_set_section_flags (dynobj, htab->srelgot, 472 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS 473 | SEC_IN_MEMORY | SEC_LINKER_CREATED 474 | SEC_READONLY)) |
474 || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) | 475 || ! bfd_set_section_alignment (dynobj, htab->srelgot, 3)) |
475 return false; 476 return true; 477} 478 479/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and 480 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our 481 hash table. */ 482 --- 22 unchanged lines hidden (view full) --- 505 abort (); 506 507 return true; 508} 509 510/* Copy the extra info we tack onto an elf_link_hash_entry. */ 511 512static void | 476 return false; 477 return true; 478} 479 480/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and 481 .rela.bss sections in DYNOBJ, and set up shortcuts to them in our 482 hash table. */ 483 --- 22 unchanged lines hidden (view full) --- 506 abort (); 507 508 return true; 509} 510 511/* Copy the extra info we tack onto an elf_link_hash_entry. */ 512 513static void |
513elf_s390_copy_indirect_symbol (dir, ind) | 514elf_s390_copy_indirect_symbol (bed, dir, ind) 515 struct elf_backend_data *bed; |
514 struct elf_link_hash_entry *dir, *ind; 515{ 516 struct elf_s390_link_hash_entry *edir, *eind; 517 518 edir = (struct elf_s390_link_hash_entry *) dir; 519 eind = (struct elf_s390_link_hash_entry *) ind; 520 521 if (eind->dyn_relocs != NULL) --- 25 unchanged lines hidden (view full) --- 547 } 548 *pp = edir->dyn_relocs; 549 } 550 551 edir->dyn_relocs = eind->dyn_relocs; 552 eind->dyn_relocs = NULL; 553 } 554 | 516 struct elf_link_hash_entry *dir, *ind; 517{ 518 struct elf_s390_link_hash_entry *edir, *eind; 519 520 edir = (struct elf_s390_link_hash_entry *) dir; 521 eind = (struct elf_s390_link_hash_entry *) ind; 522 523 if (eind->dyn_relocs != NULL) --- 25 unchanged lines hidden (view full) --- 549 } 550 *pp = edir->dyn_relocs; 551 } 552 553 edir->dyn_relocs = eind->dyn_relocs; 554 eind->dyn_relocs = NULL; 555 } 556 |
555 _bfd_elf_link_hash_copy_indirect (dir, ind); | 557 _bfd_elf_link_hash_copy_indirect (bed, dir, ind); |
556} 557 558/* Look through the relocs for a section during the first phase, and 559 allocate space in the global offset table or procedure linkage 560 table. */ 561 562static boolean 563elf_s390_check_relocs (abfd, info, sec, relocs) --- 207 unchanged lines hidden (view full) --- 771 772 sreloc = bfd_make_section (dynobj, name); 773 flags = (SEC_HAS_CONTENTS | SEC_READONLY 774 | SEC_IN_MEMORY | SEC_LINKER_CREATED); 775 if ((sec->flags & SEC_ALLOC) != 0) 776 flags |= SEC_ALLOC | SEC_LOAD; 777 if (sreloc == NULL 778 || ! bfd_set_section_flags (dynobj, sreloc, flags) | 558} 559 560/* Look through the relocs for a section during the first phase, and 561 allocate space in the global offset table or procedure linkage 562 table. */ 563 564static boolean 565elf_s390_check_relocs (abfd, info, sec, relocs) --- 207 unchanged lines hidden (view full) --- 773 774 sreloc = bfd_make_section (dynobj, name); 775 flags = (SEC_HAS_CONTENTS | SEC_READONLY 776 | SEC_IN_MEMORY | SEC_LINKER_CREATED); 777 if ((sec->flags & SEC_ALLOC) != 0) 778 flags |= SEC_ALLOC | SEC_LOAD; 779 if (sreloc == NULL 780 || ! bfd_set_section_flags (dynobj, sreloc, flags) |
779 || ! bfd_set_section_alignment (dynobj, sreloc, 2)) | 781 || ! bfd_set_section_alignment (dynobj, sreloc, 3)) |
780 return false; 781 } 782 elf_section_data (sec)->sreloc = sreloc; 783 } 784 785 /* If this is a global symbol, we count the number of 786 relocations we need for this symbol. */ 787 if (h != NULL) --- 62 unchanged lines hidden (view full) --- 850 851 return true; 852} 853 854/* Return the section that should be marked against GC for a given 855 relocation. */ 856 857static asection * | 782 return false; 783 } 784 elf_section_data (sec)->sreloc = sreloc; 785 } 786 787 /* If this is a global symbol, we count the number of 788 relocations we need for this symbol. */ 789 if (h != NULL) --- 62 unchanged lines hidden (view full) --- 852 853 return true; 854} 855 856/* Return the section that should be marked against GC for a given 857 relocation. */ 858 859static asection * |
858elf_s390_gc_mark_hook (abfd, info, rel, h, sym) 859 bfd *abfd; | 860elf_s390_gc_mark_hook (sec, info, rel, h, sym) 861 asection *sec; |
860 struct bfd_link_info *info ATTRIBUTE_UNUSED; 861 Elf_Internal_Rela *rel; 862 struct elf_link_hash_entry *h; 863 Elf_Internal_Sym *sym; 864{ 865 if (h != NULL) 866 { 867 switch (ELF64_R_TYPE (rel->r_info)) --- 13 unchanged lines hidden (view full) --- 881 return h->root.u.c.p->section; 882 883 default: 884 break; 885 } 886 } 887 } 888 else | 862 struct bfd_link_info *info ATTRIBUTE_UNUSED; 863 Elf_Internal_Rela *rel; 864 struct elf_link_hash_entry *h; 865 Elf_Internal_Sym *sym; 866{ 867 if (h != NULL) 868 { 869 switch (ELF64_R_TYPE (rel->r_info)) --- 13 unchanged lines hidden (view full) --- 883 return h->root.u.c.p->section; 884 885 default: 886 break; 887 } 888 } 889 } 890 else |
889 { 890 return bfd_section_from_elf_index (abfd, sym->st_shndx); 891 } | 891 return bfd_section_from_elf_index (sec->owner, sym->st_shndx); |
892 893 return NULL; 894} 895 896/* Update the got entry reference counts for the section being removed. */ 897 898static boolean 899elf_s390_gc_sweep_hook (abfd, info, sec, relocs) --- 114 unchanged lines hidden (view full) --- 1014 struct elf_s390_link_hash_table *htab; 1015 struct elf_s390_link_hash_entry * eh; 1016 struct elf_s390_dyn_relocs *p; 1017 asection *s; 1018 unsigned int power_of_two; 1019 1020 /* If this is a function, put it in the procedure linkage table. We 1021 will fill in the contents of the procedure linkage table later | 892 893 return NULL; 894} 895 896/* Update the got entry reference counts for the section being removed. */ 897 898static boolean 899elf_s390_gc_sweep_hook (abfd, info, sec, relocs) --- 114 unchanged lines hidden (view full) --- 1014 struct elf_s390_link_hash_table *htab; 1015 struct elf_s390_link_hash_entry * eh; 1016 struct elf_s390_dyn_relocs *p; 1017 asection *s; 1018 unsigned int power_of_two; 1019 1020 /* If this is a function, put it in the procedure linkage table. We 1021 will fill in the contents of the procedure linkage table later |
1022 (although we could actually do it here). */ | 1022 (although we could actually do it here). */ |
1023 if (h->type == STT_FUNC 1024 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) 1025 { 1026 if (h->plt.refcount <= 0 1027 || (! info->shared 1028 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 1029 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0 1030 && h->root.type != bfd_link_hash_undefweak --- 901 unchanged lines hidden (view full) --- 1932 } 1933 1934 break; 1935 1936 default: 1937 break; 1938 } 1939 | 1023 if (h->type == STT_FUNC 1024 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) 1025 { 1026 if (h->plt.refcount <= 0 1027 || (! info->shared 1028 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 1029 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0 1030 && h->root.type != bfd_link_hash_undefweak --- 901 unchanged lines hidden (view full) --- 1932 } 1933 1934 break; 1935 1936 default: 1937 break; 1938 } 1939 |
1940 /* Dynamic relocs are not propagated for SEC_DEBUGGING sections 1941 because such sections are not SEC_ALLOC and thus ld.so will 1942 not process them. */ |
|
1940 if (unresolved_reloc | 1943 if (unresolved_reloc |
1941 && !(info->shared 1942 && (input_section->flags & SEC_DEBUGGING) != 0 | 1944 && !((input_section->flags & SEC_DEBUGGING) != 0 |
1943 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) 1944 (*_bfd_error_handler) 1945 (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), 1946 bfd_archive_filename (input_bfd), 1947 bfd_get_section_name (input_bfd, input_section), 1948 (long) rel->r_offset, 1949 h->root.root.string); 1950 --- 383 unchanged lines hidden (view full) --- 2334 8, /* hash-table entry size */ 2335 1, /* internal relocations per external relocations */ 2336 64, /* arch_size */ 2337 8, /* file_align */ 2338 ELFCLASS64, EV_CURRENT, 2339 bfd_elf64_write_out_phdrs, 2340 bfd_elf64_write_shdrs_and_ehdr, 2341 bfd_elf64_write_relocs, | 1945 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) 1946 (*_bfd_error_handler) 1947 (_("%s(%s+0x%lx): unresolvable relocation against symbol `%s'"), 1948 bfd_archive_filename (input_bfd), 1949 bfd_get_section_name (input_bfd, input_section), 1950 (long) rel->r_offset, 1951 h->root.root.string); 1952 --- 383 unchanged lines hidden (view full) --- 2336 8, /* hash-table entry size */ 2337 1, /* internal relocations per external relocations */ 2338 64, /* arch_size */ 2339 8, /* file_align */ 2340 ELFCLASS64, EV_CURRENT, 2341 bfd_elf64_write_out_phdrs, 2342 bfd_elf64_write_shdrs_and_ehdr, 2343 bfd_elf64_write_relocs, |
2344 bfd_elf64_swap_symbol_in, |
|
2342 bfd_elf64_swap_symbol_out, 2343 bfd_elf64_slurp_reloc_table, 2344 bfd_elf64_slurp_symbol_table, 2345 bfd_elf64_swap_dyn_in, 2346 bfd_elf64_swap_dyn_out, 2347 NULL, 2348 NULL, 2349 NULL, --- 43 unchanged lines hidden --- | 2345 bfd_elf64_swap_symbol_out, 2346 bfd_elf64_slurp_reloc_table, 2347 bfd_elf64_slurp_symbol_table, 2348 bfd_elf64_swap_dyn_in, 2349 bfd_elf64_swap_dyn_out, 2350 NULL, 2351 NULL, 2352 NULL, --- 43 unchanged lines hidden --- |