From fb32909add6f1c2bfac2133d41ff1f399bc40207 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 7 Oct 1993 21:46:12 +0000 Subject: [PATCH] * aoutx.h (howto_table_std): Correct the "size" field in some entries. * reloc.c (reloc_howto_type): Change documentation to dispel any notion that the "size" field is a power-of-two indicator. --- bfd/ChangeLog | 8 ++++ bfd/reloc.c | 129 +++++++++++++++++++++++++++++--------------------- 2 files changed, 83 insertions(+), 54 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 78d05b79ce7..b7298b857ec 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +Thu Oct 7 17:34:07 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * aoutx.h (howto_table_std): Correct the "size" field in some + entries. + + * reloc.c (reloc_howto_type): Change documentation to dispel any + notion that the "size" field is a power-of-two indicator. + Thu Oct 7 10:50:38 1993 Steve Chamberlain (sac@phydeaux.cygnus.com) * coffswap.h: (bfd_swap_reloc_in): a symndx is signed. diff --git a/bfd/reloc.c b/bfd/reloc.c index acce99e8259..e4584d43e65 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -26,7 +26,7 @@ SECTION symbols; they are left alone until required, then read in en-mass and traslated into an internal form. There is a common routine <> which acts upon the - canonical form to to the actual fixup. + canonical form to do the actual fixup. Note that relocations are maintained on a per section basis, whilst symbols are maintained on a per BFD basis. @@ -295,9 +295,17 @@ CODE_FRAGMENT . unwanted data from the relocation. *} . unsigned int rightshift; . -. {* The size of the item to be relocated - 0, is one byte, 1 is 2 -. bytes, 2 is four bytes. A negative value indicates that the -. result is to be subtracted from the data. *} +. {* The size of the item to be relocated. This is *not* a +. power-of-two measure. +. 0 : one byte +. 1 : two bytes +. 2 : four bytes +. 3 : nothing done (unless special_function is nonzero) +. 4 : eight bytes +. -2 : two bytes, result should be subtracted from the +. data instead of added +. There is currently no trivial way to extract a "number of +. bytes" from a howto pointer. *} . int size; . . {* The number of bits in the item to be relocated. This is used @@ -477,7 +485,12 @@ DEFUN(bfd_perform_relocation,(abfd, return bfd_reloc_ok; } - if ((symbol->section == &bfd_und_section) && output_bfd == (bfd *)NULL) + /* If we are not producing relocateable output, return an error if + the symbol is not defined. An undefined weak symbol is + considered to have a value of zero (SVR4 ABI, p. 4-27). */ + if (symbol->section == &bfd_und_section + && (symbol->flags & BSF_WEAK) == 0 + && output_bfd == (bfd *) NULL) flag = bfd_reloc_undefined; /* If there is a function supplied to handle this relocation type, @@ -782,54 +795,57 @@ TYPEDEF bfd_reloc_code_type DESCRIPTION - The insides of a reloc code + The insides of a reloc code. The idea is that, eventually, there + will be one enumerator for every type of relocation we ever do. + Pass one of these values to <>, and it'll + return a howto pointer. + + This does mean that the application must determine the correct + enumerator value; you can't get a howto pointer from a random set + of attributes. CODE_FRAGMENT . .typedef enum bfd_reloc_code_real -. .{ -. {* 64 bits wide, simple reloc *} +. {* Basic absolute relocations *} . BFD_RELOC_64, -. {* 64 bits, PC-relative *} -. BFD_RELOC_64_PCREL, -. -. {* 32 bits wide, simple reloc *} . BFD_RELOC_32, -. {* 32 bits, PC-relative *} -. BFD_RELOC_32_PCREL, -. -. {* 16 bits wide, simple reloc *} . BFD_RELOC_16, -. {* 16 bits, PC-relative *} -. BFD_RELOC_16_PCREL, -. -. {* 8 bits wide, simple *} . BFD_RELOC_8, -. {* 8 bits wide, pc relative *} +. +. {* PC-relative relocations *} +. BFD_RELOC_64_PCREL, +. BFD_RELOC_32_PCREL, +. BFD_RELOC_24_PCREL, {* used by i960 *} +. BFD_RELOC_16_PCREL, . BFD_RELOC_8_PCREL, -. {* 8 bits wide, but used to form an address like 0xffnn *} -. BFD_RELOC_8_FFnn, . -. {* The type of reloc used to build a contructor table - at the -. moment probably a 32 bit wide abs address, but the cpu can -. choose. *} +. {* Linkage-table relative *} +. BFD_RELOC_32_BASEREL, +. BFD_RELOC_16_BASEREL, +. BFD_RELOC_8_BASEREL, . +. {* The type of reloc used to build a contructor table - at the moment +. probably a 32 bit wide abs address, but the cpu can choose. *} . BFD_RELOC_CTOR, . -. {* High 22 bits of 32-bit value; simple reloc. *} +. {* 8 bits wide, but used to form an address like 0xffnn *} +. BFD_RELOC_8_FFnn, +. +. {* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit +. word displacement, e.g. for SPARC) *} +. BFD_RELOC_32_PCREL_S2, +. +. {* High 22 bits of 32-bit value, placed into lower 22 bits of +. target word; simple reloc. *} . BFD_RELOC_HI22, -. {* Low 10 bits. *} +. {* Low 10 bits. *} . BFD_RELOC_LO10, . -. {* Reloc types used for i960/b.out. *} -. BFD_RELOC_24_PCREL, +. {* Reloc types used for i960/b.out. *} . BFD_RELOC_I960_CALLJ, . -. {* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit -. word displacement, e.g. for SPARC) *} -. BFD_RELOC_32_PCREL_S2, -. . {* now for the sparc/elf codes *} . BFD_RELOC_NONE, {* actually used *} . BFD_RELOC_SPARC_WDISP22, @@ -847,7 +863,7 @@ CODE_FRAGMENT . BFD_RELOC_SPARC_RELATIVE, . BFD_RELOC_SPARC_UA32, . -. {* this one is a.out specific? *} +. {* these are a.out specific? *} . BFD_RELOC_SPARC_BASE13, . BFD_RELOC_SPARC_BASE22, . @@ -868,37 +884,37 @@ CODE_FRAGMENT . BFD_RELOC_SPARC_LO7, . {* end-sanitize-v9 *} . -. {* Bits 27..2 of the relocation address shifted right 2 bits; -. simple reloc otherwise. *} +. {* Bits 27..2 of the relocation address shifted right 2 bits; +. simple reloc otherwise. *} . BFD_RELOC_MIPS_JMP, . -. {* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) *} +. {* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) *} . BFD_RELOC_16_PCREL_S2, . -. {* High 16 bits of 32-bit value; simple reloc. *} +. {* High 16 bits of 32-bit value; simple reloc. *} . BFD_RELOC_HI16, -. {* High 16 bits of 32-bit value but the low 16 bits will be sign -. extended and added to form the final result. If the low 16 -. bits form a negative number, we need to add one to the high value -. to compensate for the borrow when the low bits are added. *} +. {* High 16 bits of 32-bit value but the low 16 bits will be sign +. extended and added to form the final result. If the low 16 +. bits form a negative number, we need to add one to the high value +. to compensate for the borrow when the low bits are added. *} . BFD_RELOC_HI16_S, -. {* Low 16 bits. *} +. {* Low 16 bits. *} . BFD_RELOC_LO16, . -. {* 16 bit relocation relative to the global pointer. *} +. {* 16 bit relocation relative to the global pointer. *} . BFD_RELOC_MIPS_GPREL, . -. {* These are, so far, specific to HPPA processors. I'm not sure that -. some don't duplicate other reloc types, such as BFD_RELOC_32 and -. _32_PCREL. Also, many more were in the list I got that don't -. fit in well in the model BFD uses, so I've omitted them for now. -. If we do make this reloc type get used for code that really does -. implement the funky reloc types, they'll have to be added to this -. list. *} +. {* These are, so far, specific to HPPA processors. I'm not sure that some +. don't duplicate other reloc types, such as BFD_RELOC_32 and _32_PCREL. +. Also, many more were in the list I got that don't fit in well in the +. model BFD uses, so I've omitted them for now. If we do make this reloc +. type get used for code that really does implement the funky reloc types, +. they'll have to be added to this list. *} . BFD_RELOC_HPPA_32, . BFD_RELOC_HPPA_11, . BFD_RELOC_HPPA_14, . BFD_RELOC_HPPA_17, +. . BFD_RELOC_HPPA_L21, . BFD_RELOC_HPPA_R11, . BFD_RELOC_HPPA_R14, @@ -914,6 +930,7 @@ CODE_FRAGMENT . BFD_RELOC_HPPA_LR21, . BFD_RELOC_HPPA_RR14, . BFD_RELOC_HPPA_RR17, +. . BFD_RELOC_HPPA_GOTOFF_11, . BFD_RELOC_HPPA_GOTOFF_14, . BFD_RELOC_HPPA_GOTOFF_L21, @@ -927,12 +944,14 @@ CODE_FRAGMENT . BFD_RELOC_HPPA_GOTOFF_RD14, . BFD_RELOC_HPPA_GOTOFF_LR21, . BFD_RELOC_HPPA_GOTOFF_RR14, +. . BFD_RELOC_HPPA_DLT_32, . BFD_RELOC_HPPA_DLT_11, . BFD_RELOC_HPPA_DLT_14, . BFD_RELOC_HPPA_DLT_L21, . BFD_RELOC_HPPA_DLT_R11, . BFD_RELOC_HPPA_DLT_R14, +. . BFD_RELOC_HPPA_ABS_CALL_11, . BFD_RELOC_HPPA_ABS_CALL_14, . BFD_RELOC_HPPA_ABS_CALL_17, @@ -951,6 +970,7 @@ CODE_FRAGMENT . BFD_RELOC_HPPA_ABS_CALL_LR21, . BFD_RELOC_HPPA_ABS_CALL_RR14, . BFD_RELOC_HPPA_ABS_CALL_RR17, +. . BFD_RELOC_HPPA_PCREL_CALL_11, . BFD_RELOC_HPPA_PCREL_CALL_12, . BFD_RELOC_HPPA_PCREL_CALL_14, @@ -970,12 +990,14 @@ CODE_FRAGMENT . BFD_RELOC_HPPA_PCREL_CALL_LR21, . BFD_RELOC_HPPA_PCREL_CALL_RR14, . BFD_RELOC_HPPA_PCREL_CALL_RR17, +. . BFD_RELOC_HPPA_PLABEL_32, . BFD_RELOC_HPPA_PLABEL_11, . BFD_RELOC_HPPA_PLABEL_14, . BFD_RELOC_HPPA_PLABEL_L21, . BFD_RELOC_HPPA_PLABEL_R11, . BFD_RELOC_HPPA_PLABEL_R14, +. . BFD_RELOC_HPPA_UNWIND_ENTRY, . BFD_RELOC_HPPA_UNWIND_ENTRIES, . @@ -995,7 +1017,6 @@ CODE_FRAGMENT */ - /* SECTION bfd_reloc_type_lookup @@ -1048,7 +1069,7 @@ DEFUN(bfd_default_reloc_type_lookup, (abfd, code), { case BFD_RELOC_CTOR: /* The type of reloc used in a ctor, which will be as wide as the - address - so either a 64, 32, or 16 bitter.. */ + address - so either a 64, 32, or 16 bitter. */ switch (bfd_get_arch_info (abfd)->bits_per_address) { case 64: BFD_FAIL(); -- 2.30.2