static void som_print_symbol PARAMS ((bfd *, PTR,
asymbol *, bfd_print_symbol_type));
static boolean som_new_section_hook PARAMS ((bfd *, asection *));
+static boolean som_bfd_copy_private_symbol_data PARAMS ((bfd *, asymbol *,
+ bfd *, asymbol *));
static boolean som_bfd_copy_private_section_data PARAMS ((bfd *, asection *,
bfd *, asection *));
static boolean som_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
static boolean som_is_subspace PARAMS ((asection *));
static boolean som_is_container PARAMS ((asection *, asection *));
static boolean som_bfd_free_cached_info PARAMS ((bfd *));
+static boolean som_bfd_link_split_section PARAMS ((bfd *, asection *));
/* Map SOM section names to POSIX/BSD single-character symbol types.
and a field selector, return one or more appropriate SOM relocations. */
int **
-hppa_som_gen_reloc_type (abfd, base_type, format, field)
+hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff)
bfd *abfd;
int base_type;
int format;
enum hppa_reloc_field_selector_type_alt field;
+ int sym_diff;
{
int *final_type, **final_types;
- final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 3);
+ final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 6);
final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
if (!final_types || !final_type)
{
switch (base_type)
{
case R_HPPA:
+ /* The difference of two symbols needs *very* special handling. */
+ if (sym_diff)
+ {
+ final_types[0] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ final_types[1] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ if (!final_types[0] || !final_types[1] || !final_types[2])
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+ *final_types[0] = R_FSEL;
+ *final_types[1] = R_COMP2;
+ *final_types[2] = R_COMP2;
+ *final_types[3] = R_COMP1;
+ final_types[4] = final_type;
+ *final_types[4] = R_CODE_EXPR;
+ final_types[5] = NULL;
+ break;
+ }
/* PLABELs get their own relocation type. */
- if (field == e_psel
+ else if (field == e_psel
|| field == e_lpsel
|| field == e_rpsel)
{
*final_type = R_DATA_PLABEL;
break;
+ case R_HPPA_COMPLEX:
+ /* The difference of two symbols needs *very* special handling. */
+ if (sym_diff)
+ {
+ final_types[0] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ final_types[1] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ final_types[2] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ final_types[3] = (int *)bfd_alloc_by_size_t (abfd, sizeof (int));
+ if (!final_types[0] || !final_types[1] || !final_types[2])
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+ *final_types[1] = R_FSEL;
+ *final_types[1] = R_COMP2;
+ *final_types[2] = R_COMP2;
+ *final_types[3] = R_COMP1;
+ final_types[4] = final_type;
+ *final_types[4] = R_CODE_EXPR;
+ final_types[5] = NULL;
+ break;
+ }
+ else
+ break;
+
case R_HPPA_NONE:
case R_HPPA_ABS_CALL:
case R_HPPA_PCREL_CALL:
case R_FSEL:
case R_LSEL:
case R_RSEL:
+ case R_COMP1:
+ case R_COMP2:
reloc_offset = bfd_reloc->address;
break;
p += 1;
break;
+ case R_COMP1:
+ /* The only time we generate R_COMP1, R_COMP2 and
+ R_CODE_EXPR relocs is for the difference of two
+ symbols. Hence we can cheat here. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ bfd_put_8 (abfd, 0x44, p + 1);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 2, reloc_queue);
+ break;
+
+ case R_COMP2:
+ /* The only time we generate R_COMP1, R_COMP2 and
+ R_CODE_EXPR relocs is for the difference of two
+ symbols. Hence we can cheat here. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ bfd_put_8 (abfd, 0x80, p + 1);
+ bfd_put_8 (abfd, sym_num >> 16, p + 2);
+ bfd_put_16 (abfd, sym_num, p + 3);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 5, reloc_queue);
+ break;
+
+ case R_CODE_EXPR:
+ /* The only time we generate R_COMP1, R_COMP2 and
+ R_CODE_EXPR relocs is for the difference of two
+ symbols. Hence we can cheat here. */
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ subspace_reloc_size += 1;
+ p += 1;
+ break;
+
/* Put a "R_RESERVED" relocation in the stream if
we hit something we do not understand. The linker
will complain loudly if this ever happens. */
the stack. */
else if (islower (c))
{
+ int bits = (c - 'a') * 8;
for (v = 0; c > 'a'; --c)
v = (v << 8) | *fixup++;
+ if (varname == 'V')
+ v = sign_extend (v, bits);
push (v);
}
return true;
}
+/* Copy any private info we understand from the input symbol
+ to the output symbol. */
+
+static boolean
+som_bfd_copy_private_symbol_data (ibfd, isymbol, obfd, osymbol)
+ bfd *ibfd;
+ asymbol *isymbol;
+ bfd *obfd;
+ asymbol *osymbol;
+{
+ struct som_symbol *input_symbol = isymbol;
+ struct som_symbol *output_symbol = osymbol;
+
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_som_flavour
+ || obfd->xvec->flavour != bfd_target_som_flavour)
+ return false;
+
+ /* The only private information we need to copy is the argument relocation
+ bits. */
+ output_symbol->tc_data.hppa_arg_reloc = input_symbol->tc_data.hppa_arg_reloc;
+
+ return true;
+}
+
/* Copy any private info we understand from the input section
to the output section. */
static boolean
/* End of miscellaneous support functions. */
+/* Linker support functions. */
+static boolean
+som_bfd_link_split_section (abfd, sec)
+ bfd *abfd;
+ asection *sec;
+{
+ return (som_is_subspace (sec) && sec->_raw_size > 240000);
+}
+
#define som_close_and_cleanup som_bfd_free_cached_info
#define som_openr_next_archived_file bfd_generic_openr_next_archived_file
#include <lst.h>
#include <ar.h>
+/* The SOM BFD backend doesn't currently use anything from these
+ two include files, but it's likely to need them in the future. */
+#ifdef R_DLT_REL
+#include <shl.h>
+#include <dl.h>
+#endif
#if defined(HOST_HPPABSD) || defined (HOST_HPPAOSF)
/* BSD uses a completely different scheme for object file identification.
need not be copied for objcopy or strip to work. */
som_symbol_type *symtab;
char *stringtab;
+ asymbol **sorted_syms;
/* We remember these offsets so that after check_file_format, we have
no dependencies on the particular format of the exec_hdr.
#define obj_som_str_filepos(bfd) (somdata(bfd).str_filepos)
#define obj_som_stringtab_size(bfd) (somdata(bfd).stringtab_size)
#define obj_som_reloc_filepos(bfd) (somdata(bfd).reloc_filepos)
+#define obj_som_sorted_syms(bfd) (somdata(bfd).sorted_syms)
#define som_section_data(sec) \
((struct som_section_data_struct *)sec->used_by_bfd)
#define som_symbol_data(symbol) ((som_symbol_type *) symbol)
void bfd_som_set_symbol_type PARAMS ((asymbol *, unsigned int));
boolean bfd_som_attach_aux_hdr PARAMS ((bfd *, int, char *));
int ** hppa_som_gen_reloc_type
- PARAMS ((bfd *, int, int, enum hppa_reloc_field_selector_type_alt));
+ PARAMS ((bfd *, int, int, enum hppa_reloc_field_selector_type_alt, int));
#endif /* _SOM_H */