From 1cd8ff388206c878587561b6339d147fda189aa7 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 11 Jan 2002 09:27:39 +0000 Subject: [PATCH] Add support for ia64-hpux target. --- gas/ChangeLog | 16 +++++++++ gas/config/tc-ia64.c | 79 ++++++++++++++++++++++++++++++++------------ gas/config/tc-ia64.h | 6 +++- 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 2597a25b897..4e7a11e74aa 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,19 @@ +2002-01-11 Steve Ellcey + + * gas/config/tc-ia64.h (MD_FLAGS_DEFAULT): New Macro for + setting default md.flags. + (SHT_INIT_ARRAY): New elf special section used by HP-UX. + (SHT_FINI_ARRAY): New elf special section used by HP-UX. + * gas/config/tc-ia64.c (setup_unwind_header): Add support + for 32 bit unwind info blocks. + (generate_unwind_image): Add support for different types + of unwind images (32 bits and/or big-endian). + (ia64_init): Use MD_FLAGS_DEFAULT to set md.flags. + (ia64_target_format): Add support for hpux target formats. + (ia64_gen_real_reloc_type): Add support for FUNC_IPLT_RELOC. + (ia64_elf_section_type): Add support for SHT_INIT_ARRAY and + SHT_FINI_ARRAY elf section types. + 2002-01-10 Richard Earnshaw * tc-arm.c (struct reg_entry): Move before prototypes. diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index fa51977c2d7..701752f47eb 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -1,5 +1,5 @@ /* tc-ia64.c -- Assembler for the HP/Intel IA-64 architecture. - Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by David Mosberger-Tang This file is part of GAS, the GNU Assembler. @@ -950,23 +950,28 @@ ia64_elf_section_type (str, len) const char *str; size_t len; { - len = sizeof (ELF_STRING_ia64_unwind_info) - 1; - if (strncmp (str, ELF_STRING_ia64_unwind_info, len) == 0) +#define STREQ(s) ((len == sizeof (s) - 1) && (strncmp (str, s, sizeof (s) - 1) == 0)) + + if (STREQ (ELF_STRING_ia64_unwind_info)) return SHT_PROGBITS; - len = sizeof (ELF_STRING_ia64_unwind_info_once) - 1; - if (strncmp (str, ELF_STRING_ia64_unwind_info_once, len) == 0) + if (STREQ (ELF_STRING_ia64_unwind_info_once)) return SHT_PROGBITS; - len = sizeof (ELF_STRING_ia64_unwind) - 1; - if (strncmp (str, ELF_STRING_ia64_unwind, len) == 0) + if (STREQ (ELF_STRING_ia64_unwind)) return SHT_IA_64_UNWIND; - len = sizeof (ELF_STRING_ia64_unwind_once) - 1; - if (strncmp (str, ELF_STRING_ia64_unwind_once, len) == 0) + if (STREQ (ELF_STRING_ia64_unwind_once)) return SHT_IA_64_UNWIND; + if (STREQ ("init_array")) + return SHT_INIT_ARRAY; + + if (STREQ ("fini_array")) + return SHT_FINI_ARRAY; + return -1; +#undef STREQ } static unsigned int @@ -2791,6 +2796,7 @@ static int setup_unwind_header (int size, unsigned char **mem) { int x, extra = 0; + valueT flag_value; /* pad to pointer-size boundry. */ x = size % md.pointer_size; @@ -2803,13 +2809,22 @@ setup_unwind_header (int size, unsigned char **mem) /* Clear the padding area and personality. */ memset (*mem + 8 + size, 0 , extra + md.pointer_size); + /* Initialize the header area. */ + if (unwind.personality_routine) + { + if (md.flags & EF_IA_64_ABI64) + flag_value = (bfd_vma) 3 << 32; + else + /* 32-bit unwind info block. */ + flag_value = (bfd_vma) 0x1003 << 32; + } + else + flag_value = 0; - md_number_to_chars (*mem, (((bfd_vma) 1 << 48) /* version */ - | (unwind.personality_routine - ? ((bfd_vma) 3 << 32) /* U & E handler flags */ - : 0) - | ((size + extra) / md.pointer_size)), /* length */ + md_number_to_chars (*mem, (((bfd_vma) 1 << 48) /* Version. */ + | flag_value /* U & E handler flags. */ + | ((size + extra) / md.pointer_size)), /* Length. */ 8); return extra; @@ -3220,6 +3235,7 @@ generate_unwind_image (text_name) unsigned char *where; char *sec_name; expressionS exp; + bfd_reloc_code_real_type reloc; make_unw_section_name (SPECIAL_SECTION_UNWIND_INFO, text_name, sec_name); set_section (sec_name); @@ -3249,8 +3265,24 @@ generate_unwind_image (text_name) exp.X_op = O_symbol; exp.X_add_symbol = unwind.personality_routine; exp.X_add_number = 0; - fix_new_exp (frag_now, frag_now_fix () - 8, 8, - &exp, 0, BFD_RELOC_IA64_LTOFF_FPTR64LSB); + + if (md.flags & EF_IA_64_BE) + { + if (md.flags & EF_IA_64_ABI64) + reloc = BFD_RELOC_IA64_LTOFF_FPTR64MSB; + else + reloc = BFD_RELOC_IA64_LTOFF_FPTR32MSB; + } + else + { + if (md.flags & EF_IA_64_ABI64) + reloc = BFD_RELOC_IA64_LTOFF_FPTR64LSB; + else + reloc = BFD_RELOC_IA64_LTOFF_FPTR32LSB; + } + + fix_new_exp (frag_now, frag_now_fix () - md.pointer_size, + md.pointer_size, & exp, 0, reloc); unwind.personality_routine = 0; } } @@ -6614,9 +6646,7 @@ ia64_init (argc, argv) int argc ATTRIBUTE_UNUSED; char **argv ATTRIBUTE_UNUSED; { - md.flags = EF_IA_64_ABI64; - if (TARGET_BYTES_BIG_ENDIAN) - md.flags |= EF_IA_64_BE; + md.flags = MD_FLAGS_DEFAULT; } /* Return a string for the target object file format. */ @@ -6629,14 +6659,18 @@ ia64_target_format () if (md.flags & EF_IA_64_BE) { if (md.flags & EF_IA_64_ABI64) -#ifdef TE_AIX50 +#if defined(TE_AIX50) return "elf64-ia64-aix-big"; +#elif defined(TE_HPUX) + return "elf64-ia64-hpux-big"; #else return "elf64-ia64-big"; #endif else -#ifdef TE_AIX50 +#if defined(TE_AIX50) return "elf32-ia64-aix-big"; +#elif defined(TE_HPUX) + return "elf32-ia64-hpux-big"; #else return "elf32-ia64-big"; #endif @@ -10024,6 +10058,9 @@ ia64_gen_real_reloc_type (sym, r_type) } break; + case FUNC_IPLT_RELOC: + break; + default: abort (); } diff --git a/gas/config/tc-ia64.h b/gas/config/tc-ia64.h index 320798b50b3..53dab86447a 100644 --- a/gas/config/tc-ia64.h +++ b/gas/config/tc-ia64.h @@ -1,5 +1,5 @@ /* tc-ia64.h -- Header file for tc-ia64.c. - Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Contributed by David Mosberger-Tang This file is part of GAS, the GNU Assembler. @@ -28,9 +28,11 @@ #ifdef TE_HPUX #define md_number_to_chars number_to_chars_bigendian #define TARGET_BYTES_BIG_ENDIAN 1 +#define MD_FLAGS_DEFAULT EF_IA_64_BE #else #define md_number_to_chars number_to_chars_littleendian #define TARGET_BYTES_BIG_ENDIAN 0 +#define MD_FLAGS_DEFAULT EF_IA_64_ABI64 #endif /* TE_HPUX */ /* We need to set the default object file format in ia64_init and not in @@ -122,6 +124,8 @@ extern void ia64_after_parse_args PARAMS ((void)); #define WORKING_DOT_WORD /* don't do broken word processing for now */ #define ELF_TC_SPECIAL_SECTIONS \ +{ ".init_array",SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE }, \ +{ ".fini_array",SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE }, \ { ".sbss", SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, \ { ".sdata", SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, -- 2.30.2