aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@cygnus>1993-06-02 21:24:35 +0000
committerKen Raeburn <raeburn@cygnus>1993-06-02 21:24:35 +0000
commit7050286db6c6aeae6a65803a34978ee9e01b5c04 (patch)
tree3ef3b70f9498345f686f38d8b3809f242b682b03
parentcef91d759ccb09252c953a954b8d527f176ef247 (diff)
downloadgdb-7050286db6c6aeae6a65803a34978ee9e01b5c04.zip
gdb-7050286db6c6aeae6a65803a34978ee9e01b5c04.tar.gz
gdb-7050286db6c6aeae6a65803a34978ee9e01b5c04.tar.bz2
elfcode.h
-rw-r--r--bfd/ChangeLog64
-rw-r--r--bfd/elf32-hppa.h464
-rw-r--r--bfd/elf32-target.h15
-rw-r--r--bfd/hppa.c545
-rw-r--r--bfd/libelf.h71
5 files changed, 882 insertions, 277 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c2d8998..2b60ac6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,67 @@
+Tue Jun 1 04:15:57 1993 Ken Raeburn (raeburn@kr-pc.cygnus.com)
+
+ * elf.c: New file, for word-size independent code.
+ * elfcode.h (elf_hash): Moved to there, renamed bfd_elf_hash.
+ * Makefile.in: Include elf.o in standard objects.
+
+ * bfd-in.h (CAT3): Define here.
+ * libaout.h, libelf.h: Not here.
+
+ * libelf.h (struct strtab): Define here.
+ (bfd_elf_locate_sh): Declare here.
+ * elfcode.h (struct strtab): Definition deleted.
+
+ * reloc.c (enum bfd_reloc_code_real): Added HPPA_PCREL_CALL_12.
+
+ * Makefile.in: Make "all", not "bfd.h", be the default target.
+ (stmp-bfd.h): New target; prevents rebuilding world if bfd.h
+ hasn't really changed.
+
+ Tue May 25 12:15:15 1993 Michael Meissner (meissner@osf.org)
+
+ * elfcode.h (elf_hash): Provide elf standard hash function.
+ (various): Key off of the machines use_rela_p field to determine
+ whether to use REL or RELA relocations.
+ (elf_swap_reloc_out, elf_swap_reloc_in): New functions.
+ (elf_make_sections): Allocate a pointer to hold all data for a
+ given section, and copy each fragment into the data region.
+ Update the section's pointer with the REL implicit addends if the
+ machine uses REL relocation.
+
+ * elf32-i386.c (elf_bfd_reloc_type_lookup): Rename to
+ elf_i386_bfd_reloc_type_lookup, and use cpp to map the name back
+ into was elf32-target.h expects.
+ (elf_info_to_howto): Rename to elf_i386_info_to_howto.
+ (elf_i386_bfd_reloc_type_lookup): Add relocation support.
+ (elf_i386_info_to_howto): Add minimal relocation support.
+
+ * libelf.h (elf_backend_data): Add use_rela_p, elf_64_p,
+ elf_info_to_howto_rel fields.
+
+ * elf32-target.h (elf_bed): Add support for new fields in
+ elf_backend_data.
+
+ Sun May 30 16:38:24 1993 Peter Hoogenboom (hoogen@fast.cs.utah.edu)
+
+ * elf32-hppa.c: Add symbol extension section support, fix
+ relocation howto table, add stub generation support.
+
+ * elf32-hppa.h: Add symbol extension section support, fix
+ relocation howto table, add stub generation support.
+
+ * elfcode.h (bfd_elf_locate_sh): New function to locate ELF
+ section header.
+ (bfd_add_to_strtab):
+ (elf_idx_of_sym):
+ (elf_compute_section_file_positions):
+ (elf_write_object_contents):
+ (elf_get_sect_thunk):
+
+ * hppa.c (sign_ext): Reimplement.
+
+ * hppa.c (round_down,round,round_up,L,R,LS,RS,LD,RD,LR,RR): Make
+ these functions static.
+
Tue Jun 1 14:40:41 1993 Per Bothner (bothner@rtl.cygnus.com)
* Makefile.in (bfd.h): Move closer to headers - and after 'all'!
diff --git a/bfd/elf32-hppa.h b/bfd/elf32-hppa.h
new file mode 100644
index 0000000..e392eeb
--- /dev/null
+++ b/bfd/elf32-hppa.h
@@ -0,0 +1,464 @@
+/* ELF32/HPPA relocation support
+
+ This file contains ELF32/HPPA relocation support as specified
+ in the Stratus FTX/Golf Object File Format (SED-1762) dated
+ November 19, 1992.
+*/
+
+
+/*
+ Copyright (C) 1990-1991 Free Software Foundation, Inc.
+
+ Written by:
+
+ Center for Software Science
+ Department of Computer Science
+ University of Utah
+
+This file is part of BFD, the Binary File Descriptor library.
+
+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
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#ifndef _ELF32_HPPA_H
+#define _ELF32_HPPA_H
+
+#include "libelf.h"
+
+/* 9.3.3. Parameter relocation information */
+
+/* As mentioned previously, relocations of calls must be accompanied */
+/* by parameter relocation information, indicating which registers the */
+/* first for parameter words, and the return value, are located in. */
+/* This information accompanies the R_HPPA_ABS_CALL.., */
+/* R_HPPA_PCREL_CALL... and R_HPPA_PUSH_PROC relocation types, */
+/* described below. The information is kept in the high-order 10 bits */
+/* of Elf32_rela.r_addend, while the low-order 22 bits are a signed */
+/* constant to be used in calculating the call target. The following */
+/* macros are used to extract and combine these data in r_addend. */
+
+#define ELF32_HPPA_R_ARG_RELOC(a) (((a) >> 22) & 0x3FF)
+#define ELF32_HPPA_R_CONSTANT(a) ((((Elf32_Sword)(a)) << 10) >> 10)
+#define ELF32_HPPA_R_ADDEND(r,c) (((r) << 22) + ((c) & 0x3FFFFF))
+
+/* ELF/HPPA relocation types */
+
+/* name expression format */
+/* -------------------------------------------------------------- */
+typedef enum
+ {
+ /* 9.3.4. Address relocation types */
+
+ /* These relocation types do simple base+offset relocations, and are */
+ /* normally used for absolute references to data. */
+
+ /* By convention, relocation type zero is always "no relocation", */
+ /* while type one is 32-bit word relocation. */
+
+ R_HPPA_NONE, /* - - */
+
+ R_HPPA_32, /* Symbol + Addend 32 */
+ R_HPPA_11, /* Symbol + Addend 11 */
+ R_HPPA_14, /* Symbol + Addend 11 */
+ R_HPPA_17, /* Symbol + Addend 11 */
+ R_HPPA_L21, /* L (Symbol, Addend) 21 */
+ R_HPPA_R11, /* R (Symbol, Addend) 11 */
+ R_HPPA_R14, /* R (Symbol, Addend) 14 */
+ R_HPPA_R17, /* R (Symbol, Addend) 17 */
+ R_HPPA_LS21, /* LS(Symbol, Addend) 21 */
+ R_HPPA_RS11, /* RS(Symbol, Addend) 11 */
+ R_HPPA_RS14, /* RS(Symbol, Addend) 14 */
+ R_HPPA_RS17, /* RS(Symbol, Addend) 17 */
+ R_HPPA_LD21, /* LD(Symbol, Addend) 21 */
+ R_HPPA_RD11, /* RD(Symbol, Addend) 11 */
+ R_HPPA_RD14, /* RD(Symbol, Addend) 14 */
+ R_HPPA_RD17, /* RD(Symbol, Addend) 17 */
+ R_HPPA_LR21, /* LR(Symbol, Addend) 21 */
+ R_HPPA_RR14, /* RR(Symbol, Addend) 14 */
+ R_HPPA_RR17, /* RR(Symbol, Addend) 17 */
+
+ /* 9.3.5. GOTOFF address relocation types */
+
+ /* The Global Offset Table (GOT) is a table of pointers to data, but */
+ /* its address can also be used as a base pointer to address data, */
+ /* similar to the way the DP is used in HP/UX. The expression */
+ /* calculation yields a signed offset of an address from the GOT. */
+
+ R_HPPA_GOTOFF_11, /* Symbol - GOT + Addend 11 */
+ R_HPPA_GOTOFF_14, /* Symbol - GOT + Addend 14 */
+ R_HPPA_GOTOFF_L21, /* L (Sym - GOT, Addend) 21 */
+ R_HPPA_GOTOFF_R11, /* R (Sym - GOT, Addend) 11 */
+ R_HPPA_GOTOFF_R14, /* R (Sym - GOT, Addend) 14 */
+ R_HPPA_GOTOFF_LS21, /* LS(Sym - GOT, Addend) 21 */
+ R_HPPA_GOTOFF_RS11, /* RS(Sym - GOT, Addend) 11 */
+ R_HPPA_GOTOFF_RS14, /* RS(Sym - GOT, Addend) 14 */
+ R_HPPA_GOTOFF_LD21, /* LD(Sym - GOT, Addend) 21 */
+ R_HPPA_GOTOFF_RD11, /* RD(Sym - GOT, Addend) 11 */
+ R_HPPA_GOTOFF_RD14, /* RD(Sym - GOT, Addend) 14 */
+ R_HPPA_GOTOFF_LR21, /* LR(Sym - GOT, Addend) 21 */
+ R_HPPA_GOTOFF_RR14, /* RR(Sym - GOT, Addend) 14 */
+
+ /* 9.3.6. Absolute call relocation types */
+
+ /* Relocations of function calls must be accompanied by parameter */
+ /* relocation information. This information is carried in the ten */
+ /* high-order bits of the addend field. The remaining 22 bits of */
+ /* of the addend field are sign-extended to form the Addend. */
+
+ R_HPPA_ABS_CALL_11, /* Symbol + Addend 11 */
+ R_HPPA_ABS_CALL_14, /* Symbol + Addend 14 */
+ R_HPPA_ABS_CALL_17, /* Symbol + Addend 17 */
+ R_HPPA_ABS_CALL_L21, /* L (Symbol, Addend) 21 */
+ R_HPPA_ABS_CALL_R11, /* R (Symbol, Addend) 11 */
+ R_HPPA_ABS_CALL_R14, /* R (Symbol, Addend) 14 */
+ R_HPPA_ABS_CALL_R17, /* R (Symbol, Addend) 17 */
+ R_HPPA_ABS_CALL_LS21, /* LS(Symbol, Addend) 21 */
+ R_HPPA_ABS_CALL_RS11, /* RS(Symbol, Addend) 11 */
+ R_HPPA_ABS_CALL_RS14, /* RS(Symbol, Addend) 14 */
+ R_HPPA_ABS_CALL_RS17, /* RS(Symbol, Addend) 17 */
+ R_HPPA_ABS_CALL_LD21, /* LD(Symbol, Addend) 21 */
+ R_HPPA_ABS_CALL_RD11, /* RD(Symbol, Addend) 11 */
+ R_HPPA_ABS_CALL_RD14, /* RD(Symbol, Addend) 14 */
+ R_HPPA_ABS_CALL_RD17, /* RD(Symbol, Addend) 17 */
+ R_HPPA_ABS_CALL_LR21, /* LR(Symbol, Addend) 21 */
+ R_HPPA_ABS_CALL_RR14, /* RR(Symbol, Addend) 14 */
+ R_HPPA_ABS_CALL_RR17, /* RR(Symbol, Addend) 17 */
+
+ /* 9.3.7. PC-relative call relocation types */
+
+ /* PC-relative relocation calculates the difference between an address */
+ /* and the location being relocated. This is most often used to */
+ /* relocate pc-relative calls. */
+
+ /* As with the ABS_CALL relocation types, the ten high-order bits of */
+ /* the addend field carry parameter relocation information, while */
+ /* the low-order 22 bits are sign-extended to form the Addend. */
+
+ R_HPPA_PCREL_CALL_11, /* Symbol - PC + Addend 11 */
+ R_HPPA_PCREL_CALL_14, /* Symbol - PC + Addend 14 */
+ R_HPPA_PCREL_CALL_17, /* Symbol - PC + Addend 17 */
+ R_HPPA_PCREL_CALL_12, /* Symbol - PC + Addend 12 */
+ R_HPPA_PCREL_CALL_L21, /* L (Symbol - PC, Addend) 21 */
+ R_HPPA_PCREL_CALL_R11, /* R (Symbol - PC, Addend) 11 */
+ R_HPPA_PCREL_CALL_R14, /* R (Symbol - PC, Addend) 14 */
+ R_HPPA_PCREL_CALL_R17, /* R (Symbol - PC, Addend) 17 */
+ R_HPPA_PCREL_CALL_LS21, /* LS(Symbol - PC, Addend) 21 */
+ R_HPPA_PCREL_CALL_RS11, /* RS(Symbol - PC, Addend) 11 */
+ R_HPPA_PCREL_CALL_RS14, /* RS(Symbol - PC, Addend) 14 */
+ R_HPPA_PCREL_CALL_RS17, /* RS(Symbol - PC, Addend) 17 */
+ R_HPPA_PCREL_CALL_LD21, /* LD(Symbol - PC, Addend) 21 */
+ R_HPPA_PCREL_CALL_RD11, /* RD(Symbol - PC, Addend) 11 */
+ R_HPPA_PCREL_CALL_RD14, /* RD(Symbol - PC, Addend) 14 */
+ R_HPPA_PCREL_CALL_RD17, /* RD(Symbol - PC, Addend) 17 */
+ R_HPPA_PCREL_CALL_LR21, /* LR(Symbol - PC, Addend) 21 */
+ R_HPPA_PCREL_CALL_RR14, /* RR(Symbol - PC, Addend) 14 */
+ R_HPPA_PCREL_CALL_RR17, /* RR(Symbol - PC, Addend) 17 *//* #69 */
+
+ /* 9.3.8. Plabel relocation types */
+
+ /* Plabels are designed to allow code pointers to be passed between */
+ /* spaces. The addend of the relocation should be either 0 (no static */
+ /* link) or 2 (static link required). These relocations correspond to */
+ /* the P%, LP% and RP% field selectors. [Description is incomplete] */
+
+ R_HPPA_PLABEL_32, /* F(Plabel(Symbol,Addend),0) 32 */
+ R_HPPA_PLABEL_11, /* F(Plabel(Symbol,Addend),0) 11 */
+ R_HPPA_PLABEL_14, /* F(Plabel(Symbol,Addend),0) 14 */
+ R_HPPA_PLABEL_L21, /* L(Plabel(Symbol,Addend),0) 21 */
+ R_HPPA_PLABEL_R11, /* R(Plabel(Symbol,Addend),0) 11 */
+ R_HPPA_PLABEL_R14, /* R(Plabel(Symbol,Addend),0) 14 */
+
+ /* 9.3.9. Data linkage table (DLT) relocation types */
+
+ /* SOM DLT_REL fixup requests are used to for static data references */
+ /* from position-independent code within shared libraries. They are */
+ /* similar to the GOT relocation types in some SVR4 implementations. */
+ /* [Prose to come] */
+
+ R_HPPA_DLT_32, /* F(DLTOFF) 32 */
+ R_HPPA_DLT_11, /* F(DLTOFF) 11 */
+ R_HPPA_DLT_14, /* F(DLTOFF) 14 */
+ R_HPPA_DLT_L21, /* L(DLTOFF) 21 */
+ R_HPPA_DLT_R11, /* R(DLTOFF) 11 */
+ R_HPPA_DLT_R14, /* R(DLTOFF) 14 */
+
+ /* 9.3.10. Relocations for unwinder tables */
+
+ /* As described above, the unwinder table consists of a series of */
+ /* four-word entries, the first two of which are a pair of code */
+ /* addresses. While it would be possible to relocate this table using */
+ /* just R_HPPA_32, the amount of relocation data resulting would be */
+ /* very large. To reduce that data, the following relocation types */
+ /* have been defined. */
+
+ /* The first, R_HPPA_UNWIND_ENTRY, merely compresses two R_HPPA_32 */
+ /* operations into one. It is designed for use in .rel-type */
+ /* relocations, where the two 32-bit addends are taken from the unwind */
+ /* section itself. */
+
+ /* The second, which is designed for use in .rela-type relocations, is */
+ /* designed to relocate an entire unwinder table with one relocation */
+ /* entry. It has the effect of multiple R_HPPA_UNWIND_ENTRY */
+ /* relocations applied to successive unwinder table entries. The */
+ /* number of entries to be relocated is given in the r_addend field of */
+ /* the relocation entry. The rest of the relocation entry is used in */
+ /* a normal way--r_offset is the offset of the first unwind entry in */
+ /* the section, while ELF32_R_SYM(r_info) is the code section that all */
+ /* the code addresses should be relocated from. */
+
+ R_HPPA_UNWIND_ENTRY, /* "128" */
+ R_HPPA_UNWIND_ENTRIES, /* Addend * "128" */
+
+ /* 9.3.11. Relocation types for complex expressions */
+
+ /* As described above, new-format SOM fixups support complex */
+ /* expressions by spreading the parts of the expression across */
+ /* multiple entries. ELF for HPPA will have a similar mechanism, */
+ /* although support for it may be optional. There are two main */
+ /* reasons for defining it: first, the need to translate complex */
+ /* SOM fixup expressions to ELF, and second, to cover combinations */
+ /* of expression, field and format not available with other */
+ /* relocation types. */
+
+ /* ELF expression relocation entries are interpreted as postfix-form */
+ /* expressions. They may be evaluated using a push-down stack. */
+
+ /* Usually, the addend field of these expression relocation entries is */
+ /* unused, with the following exceptions: */
+
+ /* R_HPPA_PUSH_CONST: The addend field contains the constant. */
+
+ /* R_HPPA_PUSH_PROC: The high-order 10 bits of the addend field */
+ /* contain parameter relocation information. The rest of */
+ /* the addend field is unused. */
+
+ /* R_HPPA_LSHIFT, R_HPPA_ARITH_RSHIFT and R_HPPA_LOGIC_RSHIFT: */
+ /* The addend field normally gives the amount to shift. */
+ /* However, if that amount is zero, the shift amount is */
+ /* popped from the top of the stack prior to popping the */
+ /* amount to be shifted. */
+
+ /* name expression fld/fmt */
+ /* ------------------------------------------------------------------- */
+ R_HPPA_PUSH_CONST, /* push Addend - - */
+ R_HPPA_PUSH_PC, /* push PC + Addend - - */
+ R_HPPA_PUSH_SYM, /* push Symbol + Addend - - */
+ R_HPPA_PUSH_GOTOFF, /* push Symbol - GOT + Addend - - */
+ R_HPPA_PUSH_ABS_CALL, /* push Symbol + Addend - - */
+ R_HPPA_PUSH_PCREL_CALL, /* push Symbol - PC + Addend - - */
+ R_HPPA_PUSH_PLABEL, /* push Plabel(Symbol) - - */
+ R_HPPA_MAX, /* pop A and B, push max(B,A) - - */
+ R_HPPA_MIN, /* pop A and B, push min(B,A) - - */
+ R_HPPA_ADD, /* pop A and B, push B + A - - */
+ R_HPPA_SUB, /* pop A and B, push B - A - - */
+ R_HPPA_MULT, /* pop A and B, push B * A - - */
+ R_HPPA_DIV, /* pop A and B, push B / A - - */
+ R_HPPA_MOD, /* pop A and B, push B % A - - */
+ R_HPPA_AND, /* pop A and B, push B & A - - */
+ R_HPPA_OR, /* pop A and B, push B | A - - */
+ R_HPPA_XOR, /* pop A and B, push B ^ A - - */
+ R_HPPA_NOT, /* pop A, push ~A - - */
+ R_HPPA_LSHIFT, /* pop A, push A << Addend - - */
+ R_HPPA_ARITH_RSHIFT, /* pop A, push A >> Addend - - */
+ R_HPPA_LOGIC_RSHIFT, /* pop A, push A >> Addend - - */
+ R_HPPA_EXPR_F, /* pop A, push A + Addend F - */
+ R_HPPA_EXPR_L, /* pop A, push L(A,Addend) L - */
+ R_HPPA_EXPR_R, /* pop A, push R(A,Addend) R - */
+ R_HPPA_EXPR_LS, /* pop A, push LS(A,Addend) LS - */
+ R_HPPA_EXPR_RS, /* pop A, push RS(A,Addend) RS - */
+ R_HPPA_EXPR_LD, /* pop A, push LD(A,Addend) LD - */
+ R_HPPA_EXPR_RD, /* pop A, push RD(A,Addend) RD - */
+ R_HPPA_EXPR_LR, /* pop A, push LR(A,Addend) LR - */
+ R_HPPA_EXPR_RR, /* pop A, push RR(A,Addend) RR - */
+
+ R_HPPA_EXPR_32, /* pop - 32 */
+ R_HPPA_EXPR_21, /* pop - 21 */
+ R_HPPA_EXPR_11, /* pop - 11 */
+ R_HPPA_EXPR_14, /* pop - 14 */
+ R_HPPA_EXPR_17, /* pop - 17 */
+ R_HPPA_EXPR_12, /* pop - 12 */
+ R_HPPA_UNIMPLEMENTED /* N/A */
+ } elf32_hppa_reloc_type;
+
+#define ELF_HOWTO_TABLE_SIZE R_HPPA_UNIMPLEMENTED + 1
+#define N_HPPA_RELOCS R_HPPA_UNIMPLEMENTED + 1
+
+/* Groups of relocations. Serves as an expression type. */
+
+#define R_HPPA R_HPPA_32
+#define R_HPPA_GOTOFF R_HPPA_GOTOFF_11
+#define R_HPPA_ABS_CALL R_HPPA_ABS_CALL_11
+#define R_HPPA_PCREL_CALL R_HPPA_PCREL_CALL_11
+#define R_HPPA_PLABEL R_HPPA_PLABEL_32
+#define R_HPPA_DLT R_HPPA_DLT_32
+#define R_HPPA_UNWIND R_HPPA_UNWIND_ENTRY
+#define R_HPPA_COMPLEX R_HPPA_PUSH_CONST
+#define R_HPPA_COMPLEX_PCREL_CALL R_HPPA_PUSH_CONST + 1
+#define R_HPPA_COMPLEX_ABS_CALL R_HPPA_PUSH_CONST + 2
+
+
+enum hppa_reloc_field_selector_type
+{
+ R_HPPA_FSEL = 0x0,
+ R_HPPA_LSSEL = 0x1,
+ R_HPPA_RSSEL = 0x2,
+ R_HPPA_LSEL = 0x3,
+ R_HPPA_RSEL = 0x4,
+ R_HPPA_LDSEL = 0x5,
+ R_HPPA_RDSEL = 0x6,
+ R_HPPA_LRSEL = 0x7,
+ R_HPPA_RRSEL = 0x8,
+ R_HPPA_PSEL = 0x9, /* P' : procedure address for shlib's */
+ R_HPPA_LPSEL = 0xa, /* LP' : L' for procedure addresses */
+ R_HPPA_RPSEL = 0xb, /* RP' : R' for procedure addresses */
+
+ R_HPPA_TSEL = 0xc, /* T' : DLT-relative offset for shlib's */
+ R_HPPA_LTSEL = 0xd, /* LT' : L' for DLT-relative offsets */
+ R_HPPA_RTSEL = 0xe /* RT' : R' for DLT-relative offsets */
+
+};
+
+#define N_HPPA_FIELD_SELECTORS 15
+
+/* for compatibility */
+enum hppa_reloc_field_selector_type_alt
+{
+ e_fsel = R_HPPA_FSEL,
+ e_lssel = R_HPPA_LSSEL,
+ e_rssel = R_HPPA_RSSEL,
+ e_lsel = R_HPPA_LSEL,
+ e_rsel = R_HPPA_RSEL,
+ e_ldsel = R_HPPA_LDSEL,
+ e_rdsel = R_HPPA_RDSEL,
+ e_lrsel = R_HPPA_LRSEL,
+ e_rrsel = R_HPPA_RRSEL,
+ e_psel = R_HPPA_PSEL, /* P' : procedure address for shlib's */
+ e_lpsel = R_HPPA_LPSEL, /* LP' : L' for procedure addresses */
+ e_rpsel = R_HPPA_RPSEL, /* RP' : R' for procedure addresses */
+
+ e_tsel = R_HPPA_TSEL, /* T' : DLT-relative offset for shlib's */
+ e_ltsel = R_HPPA_LTSEL, /* LT' : L' for DLT-relative offsets */
+ e_rtsel = R_HPPA_RTSEL /* RT' : R' for DLT-relative offsets */
+};
+
+/* PA-RISC OPCODES */
+
+#define get_opcode(insn) ((insn) & 0xfc000000) >> 26
+
+/* XXX: this list is incomplete */
+
+#define LDO 0x0d
+#define LDB 0x10
+#define LDH 0x11
+#define LDW 0x12
+#define LDWM 0x13
+#define STB 0x18
+#define STH 0x19
+#define STW 0x1a
+#define STWM 0x1b
+#define COMICLR 0x24
+#define SUBI 0x25
+#define SUBIO 0x25
+#define ADDIT 0x2c
+#define ADDITO 0x2c
+#define ADDI 0x2d
+#define ADDIO 0x2d
+#define LDIL 0x08
+#define ADDIL 0x0a
+
+#define MOVB 0x32
+#define MOVIB 0x33
+#define COMBT 0x20
+#define COMBF 0x22
+#define COMIBT 0x21
+#define COMIBF 0x23
+#define ADDBT 0x28
+#define ADDBF 0x2a
+#define ADDIBT 0x29
+#define ADDIBF 0x2b
+#define BVB 0x30
+#define BB 0x31
+
+#define BL 0x3a
+#define BLE 0x39
+#define BE 0x38
+
+#ifdef __STDC__
+elf32_hppa_reloc_type **hppa_elf_gen_reloc_type (bfd * abfd, elf32_hppa_reloc_type base_type, int format, int field);
+#else
+elf32_hppa_reloc_type **hppa_elf_gen_reloc_type ();
+#endif
+
+/*
+ * HPPA Section types
+ */
+
+#define SHT_HPPA_SYMEXTN SHT_LOPROC
+
+
+/*
+ * HPPA Symbol types
+ */
+
+#define STT_HPPA_PLABEL STT_LOPROC
+
+
+/*
+ * HPPA symbol table extension entry types
+ */
+
+#define HPPA_SXT_NULL 0x00
+#define HPPA_SXT_SYMNDX 0x01
+#define HPPA_SXT_ARG_RELOC 0x02
+
+/*
+ * These macros compose and decompose the value of a symextn entry:
+ *
+ * entry_type = ELF32_HPPA_SX_TYPE(word);
+ * entry_value = ELF32_HPPA_SX_VAL(word);
+ * word = ELF32_HPPA_SX_WORD(type,val);
+ * Se.hppa_se_info = ELF32_HPPA_SE_INFO(arg_reloc)
+ */
+
+#define ELF32_HPPA_SX_TYPE(p) ((p) >> 24)
+#define ELF32_HPPA_SX_VAL(p) ((p) & 0xFFFFFF)
+#define ELF32_HPPA_SX_WORD(type,val) (((type) << 24) + (val & 0xFFFFFF))
+
+/* The following was added facilitate implementation of the .hppa_symextn
+ section. This section is built after the symbol table is built in the
+ elf_write_object_contents routine (called from bfd_close). It is built
+ so late because it requires information that is not known until
+ the symbol and string table sections have been allocated, and
+ the symbol table has been built. */
+
+#define ELF_TC_FAKE_SECTIONS 1 /* # of "hand_made" tc-specific sections */
+#define SYMEXTN_SECTION_NAME ".hppa_symextn"
+
+extern void EXFUN (elf_hppa_tc_symbol, (bfd *, elf32_symbol_type *, int));
+extern void EXFUN (elf_hppa_tc_make_sections, (bfd *, PTR));
+
+typedef Elf32_Word symext_entryS;
+
+struct symext_chain
+{
+ symext_entryS entry;
+ struct symext_chain *next;
+};
+
+typedef struct symext_chain symext_chainS;
+
+extern symext_chainS *symext_rootP;
+extern symext_chainS *symext_lastP;
+
+#endif /* _ELF32_HPPA_H */
diff --git a/bfd/elf32-target.h b/bfd/elf32-target.h
index e26356a..c18f1b9 100644
--- a/bfd/elf32-target.h
+++ b/bfd/elf32-target.h
@@ -54,8 +54,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
static CONST struct elf32_backend_data elf32_bed =
{
- elf_info_to_howto,
- ELF_ARCH,
+#ifdef USE_REL
+ 0, /* use_rela_p */
+#else
+ 1, /* use_rela_p */
+#endif
+ 0, /* elf_64_p */
+ ELF_ARCH, /* arch */
+ elf_info_to_howto, /* elf_info_to_howto */
+#ifdef elf_info_to_howto_rel
+ elf_info_to_howto_rel, /* elf_info_to_howto_rel */
+#else
+ 0, /* elf_info_to_howto_rel */
+#endif
};
#ifdef TARGET_BIG_SYM
diff --git a/bfd/hppa.c b/bfd/hppa.c
index 4dd6148..5930339 100644
--- a/bfd/hppa.c
+++ b/bfd/hppa.c
@@ -38,7 +38,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/dir.h>
#include <signal.h>
#include <machine/reg.h>
-#include <sys/user.h> /* After a.out.h */
+#include <sys/user.h> /* After a.out.h */
#include <sys/file.h>
#include <errno.h>
@@ -70,10 +70,11 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
((__m_num) >= _PA_RISC1_1_ID && (__m_num) <= _PA_RISC_MAXID))
#endif /* _PA_RISC_ID */
-struct container {
- struct header f;
- struct som_exec_auxhdr e;
-};
+struct container
+ {
+ struct header f;
+ struct som_exec_auxhdr e;
+ };
static bfd_target *
hppa_object_setup (abfd, file_hdrp, aux_hdrp)
@@ -87,17 +88,19 @@ hppa_object_setup (abfd, file_hdrp, aux_hdrp)
asection *text, *data, *bss;
rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container));
- if (rawptr == NULL) {
- bfd_error = no_memory;
- return 0;
- }
+ if (rawptr == NULL)
+ {
+ bfd_error = no_memory;
+ return 0;
+ }
rawptr1 = (struct hppa_data_struct *) bfd_zalloc (abfd, sizeof (struct hppa_data_struct));
- if (rawptr1 == NULL) {
- bfd_error = no_memory;
- return 0;
- }
-
+ if (rawptr1 == NULL)
+ {
+ bfd_error = no_memory;
+ return 0;
+ }
+
abfd->tdata.hppa_data = rawptr1;
obj_file_hdr (abfd) = &rawptr->f;
obj_aux_hdr (abfd) = &rawptr->e;
@@ -113,17 +116,17 @@ hppa_object_setup (abfd, file_hdrp, aux_hdrp)
bfd_get_start_address (abfd) = aux_hdrp->exec_entry;
- obj_pa_symbols (abfd) = (hppa_symbol_type *)NULL;
+ obj_pa_symbols (abfd) = (hppa_symbol_type *) NULL;
bfd_get_symcount (abfd) = file_hdrp->symbol_total;
- bfd_default_set_arch_mach(abfd, bfd_arch_hppa, 0);
+ bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 0);
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
- text = bfd_make_section(abfd, ".text");
- data = bfd_make_section(abfd, ".data");
- bss = bfd_make_section(abfd, ".bss");
+ text = bfd_make_section (abfd, ".text");
+ data = bfd_make_section (abfd, ".data");
+ bss = bfd_make_section (abfd, ".bss");
text->_raw_size = aux_hdrp->exec_tsize;
data->_raw_size = aux_hdrp->exec_dsize;
@@ -133,23 +136,23 @@ hppa_object_setup (abfd, file_hdrp, aux_hdrp)
data->flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS);
bss->flags = SEC_ALLOC;
- /* The virtual memory addresses of the sections */
- text->vma = aux_hdrp->exec_tmem;
- data->vma = aux_hdrp->exec_dmem;
- bss->vma = aux_hdrp->exec_bfill;
-
- /* The file offsets of the sections */
- text->filepos = aux_hdrp->exec_tfile;
- data->filepos = aux_hdrp->exec_dfile;
-
- /* The file offsets of the relocation info */
- text->rel_filepos = 0;
- data->rel_filepos = 0;
-
- /* The file offsets of the string table and symbol table. */
- obj_sym_filepos (abfd) = file_hdrp->symbol_location;
+ /* The virtual memory addresses of the sections */
+ text->vma = aux_hdrp->exec_tmem;
+ data->vma = aux_hdrp->exec_dmem;
+ bss->vma = aux_hdrp->exec_bfill;
+
+ /* The file offsets of the sections */
+ text->filepos = aux_hdrp->exec_tfile;
+ data->filepos = aux_hdrp->exec_dfile;
+
+ /* The file offsets of the relocation info */
+ text->rel_filepos = 0;
+ data->rel_filepos = 0;
+
+ /* The file offsets of the string table and symbol table. */
+ obj_sym_filepos (abfd) = file_hdrp->symbol_location;
bfd_get_symcount (abfd) = file_hdrp->symbol_total;
- obj_str_filepos (abfd) = file_hdrp->symbol_strings_location;
+ obj_str_filepos (abfd) = file_hdrp->symbol_strings_location;
obj_stringtab_size (abfd) = file_hdrp->symbol_strings_size;
return abfd->xvec;
@@ -174,11 +177,11 @@ make_unique_section (abfd, name, num)
sect = bfd_make_section (abfd, name);
while (!sect)
{
- sprintf(altname, "%s-%d", name, num++);
+ sprintf (altname, "%s-%d", name, num++);
sect = bfd_make_section (abfd, altname);
}
- newname = bfd_alloc (abfd, strlen(sect->name) + 1);
+ newname = bfd_alloc (abfd, strlen (sect->name) + 1);
strcpy (newname, sect->name);
sect->name = newname;
@@ -199,7 +202,7 @@ setup_sections (abfd, file_hdr)
char *space_strings;
int space_index;
-/* First, read in space names */
+ /* First, read in space names */
space_strings = alloca (file_hdr->space_strings_size);
if (!space_strings)
@@ -222,7 +225,7 @@ setup_sections (abfd, file_hdr)
/* Read the space dictionary element */
if (bfd_seek (abfd, file_hdr->space_location
- + space_index * sizeof space, SEEK_SET) < 0)
+ + space_index * sizeof space, SEEK_SET) < 0)
return 0;
if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space)
return 0;
@@ -237,15 +240,15 @@ setup_sections (abfd, file_hdr)
/* Now, read in the first subspace for this space */
if (bfd_seek (abfd, file_hdr->subspace_location
- + space.subspace_index * sizeof subspace,
- SEEK_SET) < 0)
+ + space.subspace_index * sizeof subspace,
+ SEEK_SET) < 0)
return 0;
if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace)
return 0;
/* Seek back to the start of the subspaces for loop below */
if (bfd_seek (abfd, file_hdr->subspace_location
- + space.subspace_index * sizeof subspace,
- SEEK_SET) < 0)
+ + space.subspace_index * sizeof subspace,
+ SEEK_SET) < 0)
return 0;
/* Setup the section flags as appropriate (this is somewhat bogus, as
@@ -277,7 +280,7 @@ setup_sections (abfd, file_hdr)
/* Make a section out of this subspace */
subspace_asect = make_unique_section (abfd, subspace.name.n_name,
- space.subspace_index + subspace_index);
+ space.subspace_index + subspace_index);
if (!subspace_asect)
return 0;
@@ -297,10 +300,10 @@ setup_sections (abfd, file_hdr)
/* Setup the sizes for the space section based upon the info in the
last subspace of the space. */
space_asect->_cooked_size = (subspace.subspace_start - space_asect->vma)
- + subspace.subspace_length;
+ + subspace.subspace_length;
space_asect->_raw_size = (subspace.file_loc_init_value
- space_asect->filepos)
- + subspace.initialization_length;
+ + subspace.initialization_length;
}
}
@@ -311,7 +314,7 @@ hppa_object_p (abfd)
struct header file_hdr;
struct som_exec_auxhdr aux_hdr;
- if (bfd_read ((PTR) &file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
return 0;
if (!_PA_RISC_ID (file_hdr.system_id))
@@ -322,7 +325,7 @@ hppa_object_p (abfd)
switch (file_hdr.a_magic)
{
- case RELOC_MAGIC: /* I'm not really sure about all of these types... */
+ case RELOC_MAGIC: /* I'm not really sure about all of these types... */
case EXEC_MAGIC:
case SHARE_MAGIC:
case DEMAND_MAGIC:
@@ -345,19 +348,19 @@ hppa_object_p (abfd)
return 0;
}
- if (bfd_read ((PTR) &aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
+ if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
bfd_error = wrong_format;
if (!setup_sections (abfd, &file_hdr))
return 0;
- return hppa_object_setup(abfd, &file_hdr, &aux_hdr);
+ return hppa_object_setup (abfd, &file_hdr, &aux_hdr);
}
static boolean
-DEFUN(hppa_mkobject,(abfd),
- bfd *abfd)
-{
+DEFUN (hppa_mkobject, (abfd),
+ bfd * abfd)
+{
fprintf (stderr, "hppa_mkobject unimplemented\n");
fflush (stderr);
abort ();
@@ -365,8 +368,8 @@ DEFUN(hppa_mkobject,(abfd),
}
boolean
-DEFUN(hppa_write_object_contents,(abfd),
- bfd *abfd)
+DEFUN (hppa_write_object_contents, (abfd),
+ bfd * abfd)
{
fprintf (stderr, "hppa_write_object_contents unimplemented\n");
fflush (stderr);
@@ -424,15 +427,15 @@ static asymbol *
hppa_make_empty_symbol (abfd)
bfd *abfd;
{
- hppa_symbol_type *new =
- (hppa_symbol_type *)bfd_zalloc (abfd, sizeof (hppa_symbol_type));
+ hppa_symbol_type *new =
+ (hppa_symbol_type *) bfd_zalloc (abfd, sizeof (hppa_symbol_type));
new->symbol.the_bfd = abfd;
return &new->symbol;
}
-static void
-hppa_print_symbol (ignore_abfd, afile, symbol, how)
+static void
+hppa_print_symbol (ignore_abfd, afile, symbol, how)
bfd *ignore_abfd;
PTR afile;
asymbol *symbol;
@@ -464,7 +467,7 @@ hppa_set_section_contents (abfd, section, location, offset, count)
{
fprintf (stderr, "hppa_set_section_contents unimplimented\n");
fflush (stderr);
- abort();
+ abort ();
return false;
}
@@ -477,7 +480,7 @@ hppa_set_arch_mach (abfd, arch, machine)
fprintf (stderr, "hppa_set_arch_mach unimplemented\n");
fflush (stderr);
/* Allow any architecture to be supported by the hppa backend */
- return bfd_default_set_arch_mach(abfd, arch, machine);
+ return bfd_default_set_arch_mach (abfd, arch, machine);
}
static boolean
@@ -499,8 +502,8 @@ hppa_find_nearest_line (abfd, section, symbols, offset, filename_ptr,
static int
hppa_sizeof_headers (abfd, reloc)
- bfd *abfd;
- boolean reloc;
+ bfd *abfd;
+ boolean reloc;
{
fprintf (stderr, "hppa_sizeof_headers unimplemented\n");
fflush (stderr);
@@ -546,19 +549,19 @@ hppa_core_file_p (abfd)
int val;
struct corehead core_header;
- val = bfd_read ((void *)&core_header, 1, sizeof core_header, abfd);
+ val = bfd_read ((void *) &core_header, 1, sizeof core_header, abfd);
if (val <= 0)
break;
switch (core_header.type)
{
case CORE_KERNEL:
case CORE_FORMAT:
- bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */
+ bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */
break;
case CORE_EXEC:
{
struct proc_exec proc_exec;
- bfd_read ((void *)&proc_exec, 1, core_header.len, abfd);
+ bfd_read ((void *) &proc_exec, 1, core_header.len, abfd);
strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
}
break;
@@ -566,9 +569,9 @@ hppa_core_file_p (abfd)
{
struct proc_info proc_info;
core_regsec (abfd) = make_bfd_asection (abfd, ".reg",
- SEC_ALLOC+SEC_HAS_CONTENTS,
+ SEC_ALLOC + SEC_HAS_CONTENTS,
core_header.len,
- (int)&proc_info - (int)&proc_info.hw_regs,
+ (int) &proc_info - (int) &proc_info.hw_regs,
2);
bfd_read (&proc_info, 1, core_header.len, abfd);
core_signal (abfd) = proc_info.sig;
@@ -578,7 +581,7 @@ hppa_core_file_p (abfd)
break;
case CORE_DATA:
core_datasec (abfd) = make_bfd_asection (abfd, ".data",
- SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
core_header.len,
core_header.addr,
2);
@@ -588,7 +591,7 @@ hppa_core_file_p (abfd)
break;
case CORE_STACK:
core_stacksec (abfd) = make_bfd_asection (abfd, ".stack",
- SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS,
+ SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS,
core_header.len,
core_header.addr,
2);
@@ -626,93 +629,105 @@ hppa_core_file_failing_signal (abfd)
/* ARGSUSED */
static boolean
-hppa_core_file_matches_executable_p (core_bfd, exec_bfd)
+hppa_core_file_matches_executable_p (core_bfd, exec_bfd)
bfd *core_bfd, *exec_bfd;
{
- return true; /* FIXME, We have no way of telling at this point */
+ return true; /* FIXME, We have no way of telling at this point */
}
+#endif /* HOST_HPPAHPUX */
+
/* Miscellaneous Support Functions -- Control Structures and Functions
for the PA. */
-unsigned int assemble_3(x)
+unsigned int
+assemble_3 (x)
unsigned int x;
{
- return ( ( (x & 1 ) << 2 ) | ( ( x & 6 ) >> 1 ) ) & 7;
+ return (((x & 1) << 2) | ((x & 6) >> 1)) & 7;
}
-void dis_assemble_3(x,r)
+void
+dis_assemble_3 (x, r)
unsigned int x;
unsigned int *r;
{
- *r = ( ( (x & 4 ) >> 2 ) | ( ( x & 3 ) << 1 ) ) & 7;
+ *r = (((x & 4) >> 2) | ((x & 3) << 1)) & 7;
}
-unsigned int assemble_12(x,y)
- unsigned int x,y;
+unsigned int
+assemble_12 (x, y)
+ unsigned int x, y;
{
- return ( ( ( y & 1 ) << 11 ) | ( ( x & 1 ) << 10 ) | ( ( x & 0x7fe ) >> 1) ) & 0xfff;
+ return (((y & 1) << 11) | ((x & 1) << 10) | ((x & 0x7fe) >> 1)) & 0xfff;
}
-void dis_assemble_12(as12,x,y)
+void
+dis_assemble_12 (as12, x, y)
unsigned int as12;
- unsigned int *x,*y;
+ unsigned int *x, *y;
{
- *y = ( as12 & 0x800 ) >> 11;
- *x = ( ( as12 & 0x3ff ) << 1 ) | ( ( as12 & 0x400 ) >> 10 );
+ *y = (as12 & 0x800) >> 11;
+ *x = ((as12 & 0x3ff) << 1) | ((as12 & 0x400) >> 10);
}
-unsigned long assemble_17(x,y,z)
- unsigned int x,y,z;
+unsigned long
+assemble_17 (x, y, z)
+ unsigned int x, y, z;
{
unsigned long temp;
- temp = ( ( z & 1 ) << 16 ) |
- ( ( x & 0x1f ) << 11 ) |
- ( ( y & 1 ) << 10 ) |
- ( ( y & 0x7fe ) >> 1);
+ temp = ((z & 1) << 16) |
+ ((x & 0x1f) << 11) |
+ ((y & 1) << 10) |
+ ((y & 0x7fe) >> 1);
return temp & 0x1ffff;
}
-void dis_assemble_17(as17,x,y,z)
+void
+dis_assemble_17 (as17, x, y, z)
unsigned int as17;
- unsigned int *x,*y,*z;
+ unsigned int *x, *y, *z;
{
- *z = ( as17 & 0x10000 ) >> 16;
- *x = ( as17 & 0x0f800 ) >> 11;
- *y = ( ( ( as17 & 0x00400 ) >> 10 ) | ( ( as17 & 0x3ff ) << 1 ) ) & 0x7ff;
+ *z = (as17 & 0x10000) >> 16;
+ *x = (as17 & 0x0f800) >> 11;
+ *y = (((as17 & 0x00400) >> 10) | ((as17 & 0x3ff) << 1)) & 0x7ff;
}
-unsigned long assemble_21(x)
+unsigned long
+assemble_21 (x)
unsigned int x;
{
unsigned long temp;
- temp = ( ( x & 1 ) << 20 ) |
- ( ( x & 0xffe ) << 8 ) |
- ( ( x & 0xc000 ) >> 7 ) |
- ( ( x & 0x1f0000 ) >> 14 ) |
- ( ( x & 0x003000 ) >> 12 );
+ temp = ((x & 1) << 20) |
+ ((x & 0xffe) << 8) |
+ ((x & 0xc000) >> 7) |
+ ((x & 0x1f0000) >> 14) |
+ ((x & 0x003000) >> 12);
return temp & 0x1fffff;
}
-void dis_assemble_21(as21,x)
- unsigned int as21,*x;
+void
+dis_assemble_21 (as21, x)
+ unsigned int as21, *x;
{
unsigned long temp;
- temp = ( as21 & 0x100000 ) >> 20;
- temp |= ( as21 & 0x0ffe00 ) >> 8;
- temp |= ( as21 & 0x000180 ) << 7;
- temp |= ( as21 & 0x00007c ) << 14;
- temp |= ( as21 & 0x000003 ) << 12;
+ temp = (as21 & 0x100000) >> 20;
+ temp |= (as21 & 0x0ffe00) >> 8;
+ temp |= (as21 & 0x000180) << 7;
+ temp |= (as21 & 0x00007c) << 14;
+ temp |= (as21 & 0x000003) << 12;
*x = temp;
}
-unsigned long sign_ext(x,len)
- unsigned int x,len;
+#if 0
+unsigned long
+sign_ext (x, len)
+ unsigned int x, len;
{
unsigned int sign;
unsigned int result;
@@ -721,22 +736,32 @@ unsigned long sign_ext(x,len)
i = 0;
len_ones = 0;
- while ( i < len ) {
- len_ones = (len_ones << 1) | 1;
- i++;
- }
+ while (i < len)
+ {
+ len_ones = (len_ones << 1) | 1;
+ i++;
+ }
- sign = (x >> (len-1)) & 1;
+ sign = (x >> (len - 1)) & 1;
- if ( sign )
- result = ( ~0 ^ len_ones ) | ( len_ones & x );
+ if (sign)
+ result = (~0 ^ len_ones) | (len_ones & x);
else
result = len_ones & x;
return result;
}
-static unsigned int ones(n)
+#endif
+static unsigned long
+sign_ext (x, len)
+ unsigned int x, len;
+{
+ return (x << (32 - len)) >> (32 - len);
+}
+
+static unsigned int
+ones (n)
int n;
{
unsigned int len_ones;
@@ -744,40 +769,44 @@ static unsigned int ones(n)
i = 0;
len_ones = 0;
- while ( i < n ) {
- len_ones = (len_ones << 1) | 1;
- i++;
- }
+ while (i < n)
+ {
+ len_ones = (len_ones << 1) | 1;
+ i++;
+ }
return len_ones;
}
-void sign_unext(x,len,result)
- unsigned int x,len;
+void
+sign_unext (x, len, result)
+ unsigned int x, len;
unsigned int *result;
{
unsigned int len_ones;
- len_ones = ones(len);
+ len_ones = ones (len);
*result = x & len_ones;
}
-unsigned long low_sign_ext(x,len)
- unsigned int x,len;
+unsigned long
+low_sign_ext (x, len)
+ unsigned int x, len;
{
- unsigned int temp1,temp2;
+ unsigned int temp1, temp2;
unsigned int len_ones;
- len_ones = ones(len);
+ len_ones = ones (len);
- temp1 = ( x & 1 ) << (len-1);
- temp2 = ( ( x & 0xfffffffe ) & len_ones ) >> 1;
- return sign_ext( (temp1 | temp2),len);
+ temp1 = (x & 1) << (len - 1);
+ temp2 = ((x & 0xfffffffe) & len_ones) >> 1;
+ return sign_ext ((temp1 | temp2), len);
}
-void low_sign_unext(x,len,result)
- unsigned int x,len;
+void
+low_sign_unext (x, len, result)
+ unsigned int x, len;
unsigned int *result;
{
unsigned int temp;
@@ -786,14 +815,14 @@ void low_sign_unext(x,len,result)
unsigned int one_bit_at_len;
unsigned int len_ones;
- len_ones = ones(len);
- one_bit_at_len = 1 << (len-1);
+ len_ones = ones (len);
+ one_bit_at_len = 1 << (len - 1);
- sign_unext(x,len,&temp);
+ sign_unext (x, len, &temp);
sign = temp & one_bit_at_len;
- sign >>= (len-1);
+ sign >>= (len - 1);
- rest = temp & ( len_ones ^ one_bit_at_len );
+ rest = temp & (len_ones ^ one_bit_at_len);
rest <<= 1;
*result = rest | sign;
@@ -801,177 +830,177 @@ void low_sign_unext(x,len,result)
/* These work when 'y' is a power of two only. */
-long
-round_down(x,y)
-long x,y;
+static long
+round_down (x, y)
+ long x, y;
{
- return x & ~(y-1);
+ return x & ~(y - 1);
}
-long
-round(x,y)
-long x,y;
+static long
+round (x, y)
+ long x, y;
{
- return (x + y/2) & ~(y-1);
+ return (x + y / 2) & ~(y - 1);
}
-long
-round_up(x,y)
-long x,y;
+static long
+round_up (x, y)
+ long x, y;
{
- return x - (x | ~(y-1));
+ return x - (x | ~(y - 1));
}
/* L(Symbol, Addend): */
/* round_down (Symbol + Addend, 2048) */
-long
-L(Symbol, Addend)
+static long
+L (Symbol, Addend)
{
- return (round_down(Symbol + Addend, 2048)) >> 11;
+ return (round_down (Symbol + Addend, 2048)) >> 11;
}
/* R(Symbol, Addend): */
/* Symbol + Addend - round_down (Symbol + Addend, 2048) */
-long
-R(Symbol, Addend)
+static long
+R (Symbol, Addend)
{
- return Symbol + Addend - round_down (Symbol + Addend, 2048);
+ return Symbol + Addend - round_down (Symbol + Addend, 2048);
}
/* LS(Symbol, Addend): */
/* round (Symbol + Addend, 2048) */
-long
-LS(Symbol, Addend)
+static long
+LS (Symbol, Addend)
{
- return round (Symbol + Addend, 2048);
+ return round (Symbol + Addend, 2048);
}
/* RS(Symbol, Addend): */
/* Symbol + Addend - round (Symbol + Addend, 2048) */
-long
-RS(Symbol, Addend)
+static long
+RS (Symbol, Addend)
{
- return Symbol + Addend - round (Symbol + Addend, 2048);
+ return Symbol + Addend - round (Symbol + Addend, 2048);
}
/* LD(Symbol, Addend): */
/* round_up (Symbol + Addend, 2048) */
-long
-LD(Symbol, Addend)
+static long
+LD (Symbol, Addend)
{
- return (round_up (Symbol + Addend, 2048)) >> 11;
+ return (round_up (Symbol + Addend, 2048)) >> 11;
}
/* RD(Symbol, Addend): */
/* Symbol + Addend - round_up (Symbol + Addend, 2048) */
-long
-RD(Symbol, Addend)
+static long
+RD (Symbol, Addend)
{
- return Symbol + Addend - round_up (Symbol + Addend, 2048);
+ return Symbol + Addend - round_up (Symbol + Addend, 2048);
}
/* LR(Symbol, Addend): */
/* round_down (Symbol, 2048) + round (Addend, 8192) */
-long
-LR(Symbol, Addend)
+static long
+LR (Symbol, Addend)
{
- return (round_down (Symbol, 2048) + round (Addend, 8192)) >> 11;
+ return (round_down (Symbol, 2048) + round (Addend, 8192)) >> 11;
}
/* RR(Symbol, Addend): */
/* Symbol - round_down (Symbol, 2048) + */
/* Addend - round (Addend, 8192) */
-long
-RR(Symbol, Addend)
+static long
+RR (Symbol, Addend)
{
- return Symbol
- - round_down (Symbol, 2048)
- + Addend - round (Addend, 8192);
+ return Symbol
+ - round_down (Symbol, 2048)
+ + Addend - round (Addend, 8192);
}
unsigned long
-DEFUN(hppa_field_adjust, (value,constant_value,r_field),
- unsigned long value AND
- unsigned long constant_value AND
- unsigned short r_field)
+DEFUN (hppa_field_adjust, (value, constant_value, r_field),
+ unsigned long value AND
+ unsigned long constant_value AND
+ unsigned short r_field)
{
- unsigned long init_value = value;
- value += constant_value;
- switch (r_field) {
- case e_fsel: /* F : no change */
- break;
+ unsigned long init_value = value;
+ value += constant_value;
+ switch (r_field)
+ {
+ case e_fsel: /* F : no change */
+ break;
- case e_lssel: /* LS : if (bit 21) then add 0x800
+ case e_lssel: /* LS : if (bit 21) then add 0x800
arithmetic shift right 11 bits */
- if ( value & 0x00000400 )
- value += 0x800;
- value = (value & 0xfffff800) >> 11;
- BFD_ASSERT(value == LS(init_value,constant_value));
- break;
-
- case e_rssel: /* RS : Sign extend from bit 21 */
- if ( value & 0x00000400 )
- value |= 0xfffff800;
- else
- value &= 0x7ff;
- BFD_ASSERT(value == RS(init_value,constant_value));
- break;
-
- case e_lsel: /* L : Arithmetic shift right 11 bits */
- value = (value & 0xfffff800) >> 11;
- BFD_ASSERT(value == L(init_value,constant_value));
- break;
-
- case e_rsel: /* R : Set bits 0-20 to zero */
- value = value & 0x7ff;
- BFD_ASSERT(value == R(init_value,constant_value));
- break;
-
- case e_ldsel: /* LD : Add 0x800, arithmetic shift
+ if (value & 0x00000400)
+ value += 0x800;
+ value = (value & 0xfffff800) >> 11;
+ BFD_ASSERT (value == LS (init_value, constant_value));
+ break;
+
+ case e_rssel: /* RS : Sign extend from bit 21 */
+ if (value & 0x00000400)
+ value |= 0xfffff800;
+ else
+ value &= 0x7ff;
+ BFD_ASSERT (value == RS (init_value, constant_value));
+ break;
+
+ case e_lsel: /* L : Arithmetic shift right 11 bits */
+ value = (value & 0xfffff800) >> 11;
+ BFD_ASSERT (value == L (init_value, constant_value));
+ break;
+
+ case e_rsel: /* R : Set bits 0-20 to zero */
+ value = value & 0x7ff;
+ BFD_ASSERT (value == R (init_value, constant_value));
+ break;
+
+ case e_ldsel: /* LD : Add 0x800, arithmetic shift
right 11 bits */
- value += 0x800;
- value = (value & 0xfffff800) >> 11;
- BFD_ASSERT(value == LD(init_value,constant_value));
- break;
-
- case e_rdsel: /* RD : Set bits 0-20 to one */
- value |= 0xfffff800;
- BFD_ASSERT(value == RD(init_value,constant_value));
- break;
-
- case e_lrsel: /* LR : L with "rounded" constant */
- value = value + ((constant_value + 0x1000) & 0xffffe000);
- value = (value & 0xfffff800) >> 11;
- BFD_ASSERT(value == LR(init_value,constant_value));
- break;
-
- case e_rrsel: /* RR : R with "rounded" constant */
- value = value + ((constant_value + 0x1000) & 0xffffe000);
- value = (value & 0x7ff) + constant_value - ((constant_value + 0x1000) & 0xffffe000);
- BFD_ASSERT(value == RR(init_value,constant_value));
- break;
+ value += 0x800;
+ value = (value & 0xfffff800) >> 11;
+ BFD_ASSERT (value == LD (init_value, constant_value));
+ break;
- default:
- fprintf(stderr,"Unrecognized field_selector 0x%02x\n", r_field);
- break;
- }
+ case e_rdsel: /* RD : Set bits 0-20 to one */
+ value |= 0xfffff800;
+ BFD_ASSERT (value == RD (init_value, constant_value));
+ break;
+
+ case e_lrsel: /* LR : L with "rounded" constant */
+ value = value + ((constant_value + 0x1000) & 0xffffe000);
+ value = (value & 0xfffff800) >> 11;
+ BFD_ASSERT (value == LR (init_value, constant_value));
+ break;
+
+ case e_rrsel: /* RR : R with "rounded" constant */
+ value = value + ((constant_value + 0x1000) & 0xffffe000);
+ value = (value & 0x7ff) + constant_value - ((constant_value + 0x1000) & 0xffffe000);
+ BFD_ASSERT (value == RR (init_value, constant_value));
+ break;
+
+ default:
+ fprintf (stderr, "Unrecognized field_selector 0x%02x\n", r_field);
+ break;
+ }
return value;
-
+
}
/* End of miscellaneous support functions. */
-#endif /* HOST_HPPAHPUX */
#ifdef HOST_HPPABSD
- /* All the core file code for BSD needs to be rewritten cleanly. For
+/* All the core file code for BSD needs to be rewritten cleanly. For
now we do not support core files under BSD. */
#define hppa_core_file_p _bfd_dummy_target
@@ -1013,32 +1042,32 @@ bfd_target hppa_vec =
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
- (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
- |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+ (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+ | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
- /* leading_symbol_char: is the first char of a user symbol
+/* leading_symbol_char: is the first char of a user symbol
predictable, and if so what is it */
- 0,
+ 0,
' ', /* ar_pad_char */
16, /* ar_max_namelen */
- 3, /* minimum alignment */
-_do_getb64, _do_getb_signed_64, _do_putb64,
- _do_getb32, _do_getb_signed_32, _do_putb32,
- _do_getb16, _do_getb_signed_16, _do_putb16, /* data */
-_do_getb64, _do_getb_signed_64, _do_putb64,
- _do_getb32, _do_getb_signed_32, _do_putb32,
- _do_getb16, _do_getb_signed_16, _do_putb16, /* hdrs */
- { _bfd_dummy_target,
- hppa_object_p, /* bfd_check_format */
- bfd_generic_archive_p,
- hppa_core_file_p,
- },
+ 3, /* minimum alignment */
+ _do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16, /* data */
+ _do_getb64, _do_getb_signed_64, _do_putb64,
+ _do_getb32, _do_getb_signed_32, _do_putb32,
+ _do_getb16, _do_getb_signed_16, _do_putb16, /* hdrs */
+ {_bfd_dummy_target,
+ hppa_object_p, /* bfd_check_format */
+ bfd_generic_archive_p,
+ hppa_core_file_p,
+ },
{
bfd_false,
- hppa_mkobject,
+ hppa_mkobject,
_bfd_generic_mkarchive,
bfd_false
- },
+ },
{
bfd_false,
hppa_write_object_contents,
@@ -1046,7 +1075,7 @@ _do_getb64, _do_getb_signed_64, _do_putb64,
bfd_false,
},
#undef hppa
- JUMP_TABLE(hppa),
+ JUMP_TABLE (hppa),
(PTR) 0
};
diff --git a/bfd/libelf.h b/bfd/libelf.h
index 3d16ae5..220fdaf 100644
--- a/bfd/libelf.h
+++ b/bfd/libelf.h
@@ -25,44 +25,64 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "elf/internal.h"
#include "elf/external.h"
-#ifdef __STDC__
-#define CAT3(a,b,c) a##b##c
-#else
-#define CAT3(a,b,c) a/**/b/**/c
-#endif
-
-#if ARCH_SIZE==64
#ifndef NAME
+#if ARCH_SIZE==64
#define NAME(x,y) CAT3(x,64_,y)
-#endif
#else /* ARCH_SIZE==32 */
-#ifndef NAME
#define NAME(x,y) CAT3(x,32_,y)
#endif
#endif
+#define ElfNAME(X) NAME(Elf,X)
+#define elfNAME(X) NAME(elf,X)
+
typedef struct
{
asymbol symbol;
- NAME(Elf,Internal_Sym) internal_elf_sym;
- NAME(Elf,External_Sym) native_elf_sym;
+ ElfNAME (Internal_Sym) internal_elf_sym;
+ ElfNAME (External_Sym) native_elf_sym;
/* these are used for the generation of .stabX symbols (?) */
short desc;
unsigned char type;
char other;
-} NAME(elf,symbol_type);
+ union
+ {
+ unsigned int hppa_arg_reloc;
+ PTR any;
+ }
+ tc_data;
+}
-struct NAME(elf,backend_data) {
- void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
- NAME(Elf,Internal_Rela) *));
+elfNAME (symbol_type);
+
+/* Lacking nested functions and nested types, set up for mapping over
+ BFD sections to produce ELF sections. */
+typedef struct
+{
+ ElfNAME (Internal_Ehdr) * i_ehdr;
+ ElfNAME (Internal_Shdr) * i_shdrp;
+ struct strtab *shstrtab;
+ int symtab_section;
+}
+
+elf_sect_thunk;
+
+struct elfNAME(backend_data)
+{
+ int use_rela_p;
+ int elf_64_p;
enum bfd_architecture arch;
+ void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
+ ElfNAME (Internal_Rela) *));
+ void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
+ ElfNAME (Internal_Rel) *));
/* @@ I really don't think this should be here. I don't know what
global_sym is supposed to be used for, but I doubt it's something
that would be considered global, e.g., if you've got a program
reading and writing many BFDs. My hunch is that it's specific to
the output BFD. If not, put a comment here explaining why. */
- NAME(elf,symbol_type) *global_sym;
+ elfNAME (symbol_type) * global_sym;
};
extern bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
@@ -76,6 +96,8 @@ extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
file_ptr,
bfd_size_type));
+
+extern boolean elf_get_sect_thunk PARAMS ((bfd *, elf_sect_thunk *));
extern unsigned int bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *));
extern unsigned int bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **));
extern unsigned int bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
@@ -86,7 +108,7 @@ extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *));
extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *,
bfd_print_symbol_type));
extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *));
+ symbol_info *));
extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *));
extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
unsigned long));
@@ -96,9 +118,24 @@ extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *,
CONST char **,
unsigned int *));
extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean));
+extern unsigned long elf_hash PARAMS ((CONST unsigned char *));
/* If the target doesn't have reloc handling written yet: */
extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *,
Elf32_Internal_Rela *));
+#define get_elf_backend_data(abfd) \
+ ((struct elfNAME (backend_data) *) (abfd)->xvec->backend_data)
+
+struct strtab
+{
+ char *tab;
+ int nentries;
+ int length;
+};
+
+extern struct elf32_internal_shdr *
+bfd_elf_locate_sh PARAMS ((bfd *, struct strtab *,
+ struct elf32_internal_shdr *, CONST char *));
+
#endif /* _LIBELF_H_ */