More HP-UX IA64 changes
Steve Ellcey
sje@cup.hp.com
Wed Dec 19 14:39:00 GMT 2001
More information about the Binutils mailing list
Wed Dec 19 14:39:00 GMT 2001
- Previous message (by thread): Patch for ld: Use gcc for config instead of hardcoded paths
- Next message (by thread): More HP-UX IA64 changes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Here is another patch for HP-UX IA64 support. This involves adding some new macros to include/elf/ia64.h. Please let me know if any of the names are not acceptable. Some of the macros are just there for better readelf support on IA64 HP-UX, others are used by elfxx-ia64.c for ANSI COMMON and unwind support. I put them together in one patch because these are all the changes I have for these three files. If someone could review these and check them in I would greatly appreciate it. Steve Ellcey sje@cup.hp.com 2001-12-19 Steve Ellcey <sje@cup.hp.com> * include/elf/ia64.h (ELF_STRING_ia64_unwind_hdr): New Macro for HP-UX (SHT_IA_64_HP_OPT_ANOT): Ditto (PT_IA_64_HP_OPT_ANOT): Ditto (PT_IA_64_HP_HSL_ANOT): Ditto (PT_IA_64_HP_STACK): Ditto (SHN_IA_64_ANSI_COMMON): Ditto * binutils/readelf.c (get_ia64_segment_type): Add support for macros. (get_segment_type): Add support for IA64 specific macros. * bfd/elfxx-ia64.c (is_unwind_section_name): Add target vector as argument so we can handle HP-UX specially. (elfNN_ia64_copy_private_bfd_data): New for objcopy support. (elfNN_ia64_hpux_vec): New for use in is_unwind_section_name. (elfNN_hpux_backend_section_from_bfd_section): New for support of SHN_IA_64_ANSI_COMMON. (elfNN_ia64_relax_section): Add support for SHN_IA_64_ANSI_COMMON. (is_unwind_section_name): Add special HP-UX support. (elfNN_ia64_section_from_shdr): Add support for more sections. (elfNN_ia64_fake_sections): Modify is_unwind_section_name call and add support for more sections. (elfNN_ia64_additional_program_headers): Modify is_unwind_section_name call. (elfNN_ia64_modify_segment_map): Remove assumption that there is only one unwind section in segment. --- orig/src/include/elf/ia64.h Wed Dec 19 13:26:04 2001 +++ src/include/elf/ia64.h Wed Dec 19 13:39:34 2001 @@ -49,6 +49,8 @@ Foundation, Inc., 59 Temple Place - Suit #define ELF_STRING_ia64_unwind_info ".IA_64.unwind_info" #define ELF_STRING_ia64_unwind_once ".gnu.linkonce.ia64unw." #define ELF_STRING_ia64_unwind_info_once ".gnu.linkonce.ia64unwi." +/* .IA_64.unwind_hdr is only used by HP-UX. */ +#define ELF_STRING_ia64_unwind_hdr ".IA_64.unwind_hdr" /* Bits in the sh_flags field of Elf64_Shdr: */ @@ -60,6 +62,12 @@ Foundation, Inc., 59 Temple Place - Suit #define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ #define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ +/* SHT_IA_64_HP_OPT_ANOT is only generated by HPUX compilers for its + optimization annotation section. GCC does not generate it but we + want readelf to know what they are. Do not use two capital Ns in + annotate or sed will turn it into 32 or 64 during the build. */ +#define SHT_IA_64_HP_OPT_ANOT 0x60000004 + /* Bits in the p_flags field of Elf64_Phdr: */ #define PF_IA_64_NORECOV 0x80000000 @@ -69,9 +77,23 @@ Foundation, Inc., 59 Temple Place - Suit #define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ #define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ +/* HP-UX specific values for p_type in Elf64_Phdr. + These values are currently just used to make + readelf more usable on HP-UX. */ + +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + /* Possible values for d_tag in Elf64_Dyn: */ #define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) + +/* This section only used by HP-UX, The HP linker gives weak symbols + precedence over regular common symbols. We want common to override + weak. Using this common instead of SHN_COMMON does that. */ + +#define SHN_IA_64_ANSI_COMMON 0xFF00 /* ia64-specific relocation types: */ --- orig/src/binutils/readelf.c Wed Dec 19 13:26:27 2001 +++ src/binutils/readelf.c Wed Dec 19 13:39:49 2001 @@ -1842,6 +1842,10 @@ get_ia64_segment_type (type) { case PT_IA_64_ARCHEXT: return "IA_64_ARCHEXT"; case PT_IA_64_UNWIND: return "IA_64_UNWIND"; + case PT_HP_TLS: return "HP_TLS"; + case PT_IA_64_HP_OPT_ANOT: return "HP_OPT_ANNOT"; + case PT_IA_64_HP_HSL_ANOT: return "HP_HSL_ANNOT"; + case PT_IA_64_HP_STACK: return "HP_STACK"; default: break; } @@ -1903,6 +1907,9 @@ get_segment_type (p_type) { case EM_PARISC: result = get_parisc_segment_type (p_type); + break; + case EM_IA_64: + result = get_ia64_segment_type (p_type); break; default: result = NULL; --- orig/src/bfd/elfxx-ia64.c Wed Dec 19 13:26:16 2001 +++ src/bfd/elfxx-ia64.c Wed Dec 19 13:55:36 2001 @@ -163,7 +163,7 @@ static boolean elfNN_ia64_relax_section PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info, boolean *again)); static boolean is_unwind_section_name - PARAMS ((const char *)); + PARAMS ((bfd *abfd, const char *)); static boolean elfNN_ia64_section_from_shdr PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *)); static boolean elfNN_ia64_section_flags @@ -301,14 +301,20 @@ static boolean elfNN_ia64_finish_dynamic PARAMS ((bfd *abfd, struct bfd_link_info *info)); static boolean elfNN_ia64_set_private_flags PARAMS ((bfd *abfd, flagword flags)); +static boolean elfNN_ia64_copy_private_bfd_data + PARAMS ((bfd *ibfd, bfd *obfd)); static boolean elfNN_ia64_merge_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); static boolean elfNN_ia64_print_private_bfd_data PARAMS ((bfd *abfd, PTR ptr)); static enum elf_reloc_type_class elfNN_ia64_reloc_type_class PARAMS ((const Elf_Internal_Rela *)); +static boolean elfNN_ia64_hpux_vec + PARAMS ((const bfd_target *vec)); static void elfNN_hpux_post_process_headers PARAMS ((bfd *abfd, struct bfd_link_info *info)); +boolean elfNN_hpux_backend_section_from_bfd_section + PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec, int *retval)); /* ia64-specific relocation */ @@ -772,6 +778,8 @@ elfNN_ia64_relax_section (abfd, sec, lin tsec = bfd_abs_section_ptr; else if (isym.st_shndx == SHN_COMMON) tsec = bfd_com_section_ptr; + else if (isym.st_shndx == SHN_IA_64_ANSI_COMMON) + tsec = bfd_com_section_ptr; else tsec = bfd_section_from_elf_index (abfd, isym.st_shndx); @@ -973,11 +981,16 @@ elfNN_ia64_relax_section (abfd, sec, lin /* Return true if NAME is an unwind table section name. */ static inline boolean -is_unwind_section_name (name) +is_unwind_section_name (abfd, name) + bfd *abfd; const char *name; { size_t len1, len2, len3; + if (elfNN_ia64_hpux_vec (abfd->xvec) + && !strcmp(name,ELF_STRING_ia64_unwind_hdr)) + return false; + len1 = sizeof (ELF_STRING_ia64_unwind) - 1; len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1; len3 = sizeof (ELF_STRING_ia64_unwind_once) - 1; @@ -1005,6 +1018,10 @@ elfNN_ia64_section_from_shdr (abfd, hdr, switch (hdr->sh_type) { case SHT_IA_64_UNWIND: + case SHT_INIT_ARRAY: + case SHT_FINI_ARRAY: + case SHT_PREINIT_ARRAY: + case SHT_IA_64_HP_OPT_ANOT: break; case SHT_IA_64_EXT: @@ -1052,7 +1069,7 @@ elfNN_ia64_fake_sections (abfd, hdr, sec name = bfd_get_section_name (abfd, sec); - if (is_unwind_section_name (name)) + if (is_unwind_section_name (abfd, name)) { /* We don't have the sections numbered at this point, so sh_info is set later, in elfNN_ia64_final_write_processing. */ @@ -1061,6 +1078,14 @@ elfNN_ia64_fake_sections (abfd, hdr, sec } else if (strcmp (name, ELF_STRING_ia64_archext) == 0) hdr->sh_type = SHT_IA_64_EXT; + else if (strcmp (name, ".init_array") == 0) + hdr->sh_type = SHT_INIT_ARRAY; + else if (strcmp (name, ".fini_array") == 0) + hdr->sh_type = SHT_FINI_ARRAY; + else if (strcmp (name, ".preinit_array") == 0) + hdr->sh_type = SHT_PREINIT_ARRAY; + else if (strcmp (name, ".HP.opt_annot") == 0) + hdr->sh_type = SHT_IA_64_HP_OPT_ANOT; else if (strcmp (name, ".reloc") == 0) /* * This is an ugly, but unfortunately necessary hack that is @@ -1331,7 +1356,7 @@ elfNN_ia64_additional_program_headers (a /* Count how many PT_IA_64_UNWIND segments we need. */ for (s = abfd->sections; s; s = s->next) - if (is_unwind_section_name(s->name) && (s->flags & SEC_LOAD)) + if (is_unwind_section_name(abfd, s->name) && (s->flags & SEC_LOAD)) ++ret; return ret; @@ -1344,6 +1369,8 @@ elfNN_ia64_modify_segment_map (abfd) struct elf_segment_map *m, **pm; Elf_Internal_Shdr *hdr; asection *s; + boolean unwind_found; + asection *unwind_sec; /* If we need a PT_IA_64_ARCHEXT segment, it must come before all PT_LOAD segments. */ @@ -1386,8 +1413,24 @@ elfNN_ia64_modify_segment_map (abfd) if (s && (s->flags & SEC_LOAD)) { for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) - if (m->p_type == PT_IA_64_UNWIND && m->sections[0] == s) - break; + if (m->p_type == PT_IA_64_UNWIND) + { + /* Look through all sections in the unwind segment + for a match since there may be multiple sections + to a segment. */ + + unwind_sec = m->sections[0]; + unwind_found = false; + while (unwind_sec != NULL && !unwind_found) + { + if (unwind_sec == s) + unwind_found = true; + else + unwind_sec = unwind_sec -> next; + } + if (unwind_found) + break; + } if (m == NULL) { @@ -4285,6 +4328,24 @@ elfNN_ia64_set_private_flags (abfd, flag return true; } +/* Copy backend specific data from one object module to another */ +static boolean +elfNN_ia64_copy_private_bfd_data (ibfd, obfd) + bfd *ibfd, *obfd; +{ + if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) + return true; + + BFD_ASSERT (!elf_flags_init (obfd) + || (elf_elfheader (obfd)->e_flags + == elf_elfheader (ibfd)->e_flags)); + + elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; + elf_flags_init (obfd) = true; + return true; +} + /* Merge backend specific data from an object file to the output object file when linking. */ static boolean @@ -4421,6 +4482,13 @@ elfNN_ia64_reloc_type_class (rela) } } +static boolean +elfNN_ia64_hpux_vec (const bfd_target *vec) +{ + extern const bfd_target bfd_elfNN_ia64_hpux_big_vec; + return (vec == & bfd_elfNN_ia64_hpux_big_vec); +} + static void elfNN_hpux_post_process_headers (abfd, info) bfd *abfd; @@ -4431,6 +4499,21 @@ elfNN_hpux_post_process_headers (abfd, i i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HPUX; i_ehdrp->e_ident[EI_ABIVERSION] = 1; } + +boolean +elfNN_hpux_backend_section_from_bfd_section (abfd, hdr, sec, retval) + bfd *abfd ATTRIBUTE_UNUSED; + Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED; + asection *sec; + int *retval; +{ + if (bfd_is_com_section(sec)) + { + *retval = SHN_IA_64_ANSI_COMMON; + return true; + } + return false; +} #define TARGET_LITTLE_SYM bfd_elfNN_ia64_little_vec #define TARGET_LITTLE_NAME "elfNN-ia64-little" @@ -4486,6 +4569,8 @@ elfNN_hpux_post_process_headers (abfd, i #define bfd_elfNN_bfd_final_link \ elfNN_ia64_final_link +#define bfd_elfNN_bfd_copy_private_bfd_data \ + elfNN_ia64_copy_private_bfd_data #define bfd_elfNN_bfd_merge_private_bfd_data \ elfNN_ia64_merge_private_bfd_data #define bfd_elfNN_bfd_set_private_flags \ @@ -4541,6 +4626,9 @@ elfNN_hpux_post_process_headers (abfd, i #undef elf_backend_post_process_headers #define elf_backend_post_process_headers elfNN_hpux_post_process_headers + +#undef elf_backend_section_from_bfd_section +#define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section #undef ELF_MAXPAGESIZE #define ELF_MAXPAGESIZE 0x1000 /* 1K */
- Previous message (by thread): Patch for ld: Use gcc for config instead of hardcoded paths
- Next message (by thread): More HP-UX IA64 changes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list