From 249c7415a4fe4e628a2adc10dfd17b1d73cd677d Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Mon, 3 Jul 1995 23:33:21 +0000 Subject: [PATCH] * config/tc-hppa.h (MAX_RELOC_EXPANSION): Bump to 6. * config/tc-hppa.c (tc_gen_reloc, SOM version): Handle relocations for the difference of two (possibly external) symbols. (hppa_fix_adjustable): For SOM, reject reductions involving the difference of two symbols. (hppa_force_relocation): Force relocations for expressions involving the difference of two symbols. gas/bfd part of mentor-7363 --- gas/ChangeLog | 11 +++++++++++ gas/config/tc-hppa.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++---- gas/config/tc-hppa.h | 37 ++++++++++++++++++++++++++++-------- 3 files changed, 89 insertions(+), 12 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 8d779b9..9478716 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,14 @@ +Mon Jul 3 15:58:16 1995 Jeff Law (law@snake.cs.utah.edu) + + * config/tc-hppa.h (MAX_RELOC_EXPANSION): Bump to 6. + * config/tc-hppa.c (tc_gen_reloc, SOM version): Handle + relocations for the difference of two (possibly external) + symbols. + (hppa_fix_adjustable): For SOM, reject reductions involving + the difference of two symbols. + (hppa_force_relocation): Force relocations for expressions + involving the difference of two symbols. + Mon Jul 3 14:22:59 1995 Steve Chamberlain * configure[.in] (i386-*-win32): New host and target. diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index ac17501..6d124bf 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -2604,7 +2604,8 @@ tc_gen_reloc (section, fixp) codes = (bfd_reloc_code_real_type **) hppa_gen_reloc_type (stdoutput, fixp->fx_r_type, hppa_fixp->fx_r_format, - hppa_fixp->fx_r_field); + hppa_fixp->fx_r_field, + fixp->fx_subsy != NULL); for (n_relocs = 0; codes[n_relocs]; n_relocs++) ; @@ -2687,6 +2688,32 @@ tc_gen_reloc (section, fixp) switch (code) { + case R_COMP2: + /* The only time we ever use a R_COMP2 fixup is for the difference + of two symbols. With that in mind we fill in all four + relocs now and break out of the loop. */ + assert (i == 1); + relocs[0]->sym_ptr_ptr = &bfd_abs_symbol; + relocs[0]->howto = bfd_reloc_type_lookup (stdoutput, *codes[0]); + relocs[0]->address = fixp->fx_frag->fr_address + fixp->fx_where; + relocs[0]->addend = 0; + relocs[0]->sym_ptr_ptr = &fixp->fx_addsy->bsym; + relocs[1]->howto = bfd_reloc_type_lookup (stdoutput, *codes[1]); + relocs[1]->address = fixp->fx_frag->fr_address + fixp->fx_where; + relocs[1]->addend = 0; + relocs[2]->sym_ptr_ptr = &fixp->fx_subsy->bsym; + relocs[2]->howto = bfd_reloc_type_lookup (stdoutput, *codes[2]); + relocs[2]->address = fixp->fx_frag->fr_address + fixp->fx_where; + relocs[2]->addend = 0; + relocs[3]->sym_ptr_ptr = &bfd_abs_symbol; + relocs[3]->howto = bfd_reloc_type_lookup (stdoutput, *codes[3]); + relocs[3]->address = fixp->fx_frag->fr_address + fixp->fx_where; + relocs[3]->addend = 0; + relocs[4]->sym_ptr_ptr = &bfd_abs_symbol; + relocs[4]->howto = bfd_reloc_type_lookup (stdoutput, *codes[4]); + relocs[4]->address = fixp->fx_frag->fr_address + fixp->fx_where; + relocs[4]->addend = 0; + goto done; case R_PCREL_CALL: case R_ABS_CALL: relocs[i]->addend = HPPA_R_ADDEND (hppa_fixp->fx_arg_reloc, 0); @@ -2732,6 +2759,7 @@ tc_gen_reloc (section, fixp) } #endif +done: return relocs; } @@ -4100,7 +4128,7 @@ pa_build_unwind_subspace (call_info) /* Get some space to hold relocation information for the unwind descriptor. */ p = frag_more (4); - md_number_to_chars (p, 0.opcode, 4); + md_number_to_chars (p, 0, 4); /* Relocation info. for start offset of the function. */ fix_new_hppa (frag_now, p - frag_now->fr_literal, 4, @@ -4108,7 +4136,7 @@ pa_build_unwind_subspace (call_info) (expressionS *) NULL, 0, R_PARISC_DIR32, e_fsel, 32, 0, NULL); p = frag_more (4); - md_number_to_chars (p, 0.opcode, 4); + md_number_to_chars (p, 0, 4); /* Relocation info. for end offset of the function. @@ -6204,6 +6232,21 @@ hppa_fix_adjustable (fixp) /* Reject reductions of symbols in 32bit relocs. */ if (fixp->fx_r_type == R_HPPA && hppa_fix->fx_r_format == 32) return 0; + + /* Reject reductions of symbols in sym1-sym2 expressions when + the fixup will occur in a CODE subspace. + + XXX FIXME: Long term we probably want to reject all of these; + for example reducing in the debug section would lose if we ever + supported using the optimizing hp linker. */ + if (fixp->fx_addsy + && fixp->fx_subsy + && (hppa_fix->segment->flags & SEC_CODE)) + { + /* Apparently sy_used_in_reloc never gets set for sub symbols. */ + fixp->fx_subsy->sy_used_in_reloc = 1; + return 0; + } #endif /* Reject reductions of symbols in DLT relative relocs, @@ -6240,7 +6283,9 @@ hppa_force_relocation (fixp) hppa_fixp = (struct hppa_fix_struct *) fixp->tc_fix_data; #ifdef OBJ_SOM - if (fixp->fx_r_type == R_HPPA_ENTRY || fixp->fx_r_type == R_HPPA_EXIT) + if (fixp->fx_r_type == R_HPPA_ENTRY || fixp->fx_r_type == R_HPPA_EXIT + || (fixp->fx_addsy != NULL && fixp->fx_subsy != NULL + && (hppa_fixp->segment->flags & SEC_CODE) != 0)) return 1; #endif diff --git a/gas/config/tc-hppa.h b/gas/config/tc-hppa.h index c29fa1c..19cabb1 100644 --- a/gas/config/tc-hppa.h +++ b/gas/config/tc-hppa.h @@ -44,12 +44,12 @@ /* FIXME. The lack of a place to put things which are both target cpu and target format dependent makes hacks like this necessary. */ #ifdef OBJ_ELF -#include "../bfd/elf32-hppa.h" +#include "bfd/elf32-hppa.h" #define TARGET_FORMAT "elf32-hppa" #endif #ifdef OBJ_SOM -#include "../bfd/som.h" +#include "bfd/som.h" #define TARGET_FORMAT "som" #endif @@ -67,9 +67,6 @@ /* Labels are not required to have a colon for a suffix. */ #define LABELS_WITHOUT_COLONS -extern void hppa_tc_make_sections PARAMS ((bfd *)); -extern void hppa_tc_symbol PARAMS ((bfd *, elf_symbol_type *, int)); - /* FIXME. This should be static and declared in tc-hppa.c, but pa_define_label gets used outside of tc-hppa.c via tc_frob_label. Should also be PARAMized, but symbolS isn't available here. */ @@ -80,6 +77,11 @@ extern void parse_cons_expression_hppa (); extern void cons_fix_new_hppa (); extern int hppa_force_relocation (); +/* This gets called before writing the object file to make sure + things like entry/exit and proc/procend pairs match. */ +extern void pa_check_eof PARAMS ((void)); +#define tc_frob_file pa_check_eof + #define tc_frob_label(sym) pa_define_label (sym) /* The PA does not need support for either of these. */ @@ -87,14 +89,13 @@ extern int hppa_force_relocation (); #define tc_headers_hook(headers) {;} #define RELOC_EXPANSION_POSSIBLE -#define MAX_RELOC_EXPANSION 5 +#define MAX_RELOC_EXPANSION 6 /* FIXME. More things which are both HPPA and ELF specific. There is nowhere to put such things. */ #ifdef OBJ_ELF -#define elf_tc_symbol hppa_tc_symbol -#define elf_tc_make_sections hppa_tc_make_sections #define elf_tc_final_processing elf_hppa_final_processing +void elf_hppa_final_processing PARAMS ((void)); #endif /* The PA needs to parse field selectors in .byte, etc. */ @@ -121,6 +122,7 @@ extern int hppa_force_relocation (); normally appear safe to handle it completely within GAS. */ #define TC_FORCE_RELOCATION(FIXP) hppa_force_relocation (FIXP) +#ifdef OBJ_SOM /* If a symbol is imported, but never used, then the symbol should *not* end up in the symbol table. Likewise for absolute symbols with local scope. */ @@ -129,5 +131,24 @@ extern int hppa_force_relocation (); || (S_GET_SEGMENT (sym) == &bfd_abs_section \ && (sym->bsym->flags & BSF_EXPORT) == 0)) \ punt = 1 +#endif + +#ifdef OBJ_ELF +/* Arggg. The generic BFD ELF code always adds in the section->vma + to non-common symbols. This is a lose on the PA. To make matters + worse, the generic ELF code already defined obj_frob_symbol. */ +#define tc_frob_symbol(sym,punt) \ + { \ + if (S_GET_SEGMENT (sym) != &bfd_com_section \ + && S_GET_SEGMENT (sym) != &bfd_und_section) \ + S_SET_VALUE ((sym), (S_GET_VALUE (sym) - (sym)->bsym->section->vma)); \ + if ((S_GET_SEGMENT (sym) == &bfd_und_section && sym->sy_used == 0) \ + || (S_GET_SEGMENT (sym) == &bfd_abs_section \ + && (sym->bsym->flags & BSF_EXPORT) == 0)) \ + punt = 1; \ + } +#endif + +#define md_operand(x) #endif /* _TC_HPPA_H */ -- 2.7.4