/* bfd back-end for HP PA-RISC SOM objects.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Contributed by the Center for Software Science at the
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
02110-1301, USA. */
#include "alloca-conf.h"
-#include "bfd.h"
#include "sysdep.h"
+#include "bfd.h"
#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) || defined(HOST_HPPAMPEIX)
/* R_DATA_ONE_SYMBOL. */
{ 0, "L4=Sb=" }, /* 0x25 */
{ 1, "L4=Sd=" }, /* 0x26 */
- /* R_DATA_PLEBEL. */
+ /* R_DATA_PLABEL. */
{ 0, "L4=Sb=" }, /* 0x27 */
{ 1, "L4=Sd=" }, /* 0x28 */
/* R_SPACE_REF. */
{ 31, "L4=SD=" }, /* 0x6f */
{ 32, "L4=Sb=" }, /* 0x70 */
{ 33, "L4=Sd=" }, /* 0x71 */
+ /* R_DATA_GPREL. */
+ { 0, "L4=Sd=" }, /* 0x72 */
/* R_RESERVED. */
- { 0, "" }, /* 0x72 */
{ 0, "" }, /* 0x73 */
{ 0, "" }, /* 0x74 */
{ 0, "" }, /* 0x75 */
SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"),
SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"),
SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"),
- SOM_HOWTO (R_DP_RELATIVE, "R_DP_RELATIVE"),
+ SOM_HOWTO (R_DATA_GPREL, "R_DATA_GPREL"),
SOM_HOWTO (R_RESERVED, "R_RESERVED"),
SOM_HOWTO (R_RESERVED, "R_RESERVED"),
SOM_HOWTO (R_RESERVED, "R_RESERVED"),
|| field == e_lpsel
|| field == e_rpsel)
*final_type = R_DATA_PLABEL;
+ else if (field == e_fsel && format == 32)
+ *final_type = R_DATA_GPREL;
break;
case R_HPPA_COMPLEX:
return NULL;
}
+static reloc_howto_type *
+som_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+ const char *r_name)
+{
+ unsigned int i;
+
+ for (i = 0;
+ i < sizeof (som_hppa_howto_table) / sizeof (som_hppa_howto_table[0]);
+ i++)
+ if (som_hppa_howto_table[i].name != NULL
+ && strcasecmp (som_hppa_howto_table[i].name, r_name) == 0)
+ return &som_hppa_howto_table[i];
+
+ return NULL;
+}
+
/* Perform some initialization for an object. Save results of this
initialization in the BFD. */
abort ();
break;
+ case R_DATA_GPREL:
+ /* Account for any addend. */
+ if (bfd_reloc->addend)
+ p = som_reloc_addend (abfd, bfd_reloc->addend, p,
+ &subspace_reloc_size, reloc_queue);
+
+ if (sym_num < 0x10000000)
+ {
+ bfd_put_8 (abfd, bfd_reloc->howto->type, p);
+ bfd_put_8 (abfd, sym_num >> 16, p + 1);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 2);
+ p = try_prev_fixup (abfd, &subspace_reloc_size,
+ p, 4, reloc_queue);
+ }
+ else
+ abort ();
+ break;
+
case R_DATA_ONE_SYMBOL:
case R_DATA_PLABEL:
case R_CODE_PLABEL:
section (ST_DATA for DATA sections, ST_CODE for CODE sections). */
else if (som_symbol_data (sym)->som_type == SYMBOL_TYPE_UNKNOWN)
{
- if (sym->section->flags & SEC_CODE)
+ if (bfd_is_abs_section (sym->section))
+ info->symbol_type = ST_ABSOLUTE;
+ else if (sym->section->flags & SEC_CODE)
info->symbol_type = ST_CODE;
else
info->symbol_type = ST_DATA;
som_make_empty_symbol (bfd *abfd)
{
bfd_size_type amt = sizeof (som_symbol_type);
- som_symbol_type *new = bfd_zalloc (abfd, amt);
+ som_symbol_type *new_symbol_type = bfd_zalloc (abfd, amt);
- if (new == NULL)
+ if (new_symbol_type == NULL)
return NULL;
- new->symbol.the_bfd = abfd;
+ new_symbol_type->symbol.the_bfd = abfd;
- return &new->symbol;
+ return &new_symbol_type->symbol;
}
/* Print symbol information. */
return -1;
return (asect->reloc_count + 1) * sizeof (arelent *);
}
- /* There are no relocations. */
- return 0;
+
+ /* There are no relocations. Return enough space to hold the
+ NULL pointer which will be installed if som_canonicalize_reloc
+ is called. */
+ return sizeof (arelent *);
}
/* Convert relocations from SOM (external) form into BFD internal
}
static bfd_boolean
-som_find_nearest_line (bfd *abfd ATTRIBUTE_UNUSED,
- asection *section ATTRIBUTE_UNUSED,
- asymbol **symbols ATTRIBUTE_UNUSED,
- bfd_vma offset ATTRIBUTE_UNUSED,
- const char **filename_ptr ATTRIBUTE_UNUSED,
- const char **functionname_ptr ATTRIBUTE_UNUSED,
- unsigned int *line_ptr ATTRIBUTE_UNUSED)
+som_find_nearest_line (bfd *abfd,
+ asection *section,
+ asymbol **symbols,
+ bfd_vma offset,
+ const char **filename_ptr,
+ const char **functionname_ptr,
+ unsigned int *line_ptr)
{
- return FALSE;
+ bfd_boolean found;
+ asymbol *func;
+ bfd_vma low_func;
+ asymbol **p;
+
+ if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+ & found, filename_ptr,
+ functionname_ptr, line_ptr,
+ & somdata (abfd).line_info))
+ return FALSE;
+
+ if (found)
+ return TRUE;
+
+ if (symbols == NULL)
+ return FALSE;
+
+ /* Fallback: find function name from symbols table. */
+ func = NULL;
+ low_func = 0;
+
+ for (p = symbols; *p != NULL; p++)
+ {
+ som_symbol_type *q = (som_symbol_type *) *p;
+
+ if (q->som_type == SYMBOL_TYPE_ENTRY
+ && q->symbol.section == section
+ && q->symbol.value >= low_func
+ && q->symbol.value <= offset)
+ {
+ func = (asymbol *) q;
+ low_func = q->symbol.value;
+ }
+ }
+
+ if (func == NULL)
+ return FALSE;
+
+ *filename_ptr = NULL;
+ *functionname_ptr = bfd_asymbol_name (func);
+ *line_ptr = 0;
+
+ return TRUE;
}
static int
if (curr_bfd->format != bfd_object
|| curr_bfd->xvec->flavour != bfd_target_som_flavour)
{
- curr_bfd = curr_bfd->next;
+ curr_bfd = curr_bfd->archive_next;
continue;
}
(*stringsize)++;
}
- curr_bfd = curr_bfd->next;
+ curr_bfd = curr_bfd->archive_next;
}
return TRUE;
}
if (curr_bfd->format != bfd_object
|| curr_bfd->xvec->flavour != bfd_target_som_flavour)
{
- curr_bfd = curr_bfd->next;
+ curr_bfd = curr_bfd->archive_next;
continue;
}
linker requires objects begin on an even boundary. So round
up the current offset as necessary. */
curr_som_offset = (curr_som_offset + 0x1) &~ (unsigned) 1;
- curr_bfd = curr_bfd->next;
+ curr_bfd = curr_bfd->archive_next;
som_index++;
}
if (curr_bfd->format == bfd_object
&& curr_bfd->xvec->flavour == bfd_target_som_flavour)
lst.module_count++;
- curr_bfd = curr_bfd->next;
+ curr_bfd = curr_bfd->archive_next;
}
lst.module_limit = lst.module_count;
lst.dir_loc = lst_size;
#define som_bfd_is_group_section bfd_generic_is_group_section
#define som_bfd_discard_group bfd_generic_discard_group
#define som_section_already_linked _bfd_generic_section_already_linked
+#define som_bfd_define_common_symbol bfd_generic_define_common_symbol
#define som_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
#define som_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
#define som_bfd_set_private_flags _bfd_generic_bfd_set_private_flags