Changeset 1248


Ignore:
Timestamp:
Feb 15, 2004, 10:53:13 AM (21 years ago)
Author:
bird
Message:

#905: Do relocations more like ELF, ensuring we relocate to a symbol for externals & weaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/binutils/bfd/i386aoutemx.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1247 r1248  
    2424#include "bfd.h"
    2525#include "libbfd.h"
    26 #include "libaout.h"
    2726#ifndef EMX
    2827#error "EMX TARGET! EMX isn't defined!!!"
    2928#endif
    3029
    31 #define MY_object_p MY(object_p)
    32 #define MY_backend_data &MY(backend_data)
    33 
    34 static bfd_boolean MY(set_sizes) PARAMS ((bfd *));
    35 static const bfd_target *MY(object_p) PARAMS ((bfd *));
    36 
    37 static CONST struct aout_backend_data MY(backend_data) = {
     30#include <symcat.h>
     31#define MY_object_p                 MY(object_p)
     32#define MY_backend_data            &MY(backend_data)
     33#define MY_bfd_reloc_type_lookup    i386aout_emx_reloc_type_lookup
     34
     35#include "libaout.h"
     36#include "aout/aout64.h"
     37
     38static bfd_boolean      MY(set_sizes) PARAMS ((bfd *));
     39const bfd_target *      MY(object_p) PARAMS ((bfd *));
     40reloc_howto_type *      MY(reloc_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
     41bfd_reloc_status_type   MY(generic_reloc) PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
     42/*reloc_howto_type *  MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));*/
     43
     44reloc_howto_type MY(howto_table_std)[] =
     45{
     46  /* type              rs size bsz  pcrel bitpos ovrf                     sf                name      part_inpl readmask  setmask    pcdone.  */
     47HOWTO ( 0,             0,  0,   8,  FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"8",        TRUE, 0x000000ff,0x000000ff, FALSE),
     48HOWTO ( 1,             0,  1,   16, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"16",       TRUE, 0x0000ffff,0x0000ffff, FALSE),
     49HOWTO ( 2,             0,  2,   32, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"32",       TRUE, 0xffffffff,0xffffffff, FALSE),
     50HOWTO ( 3,             0,  4,   64, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"64",       TRUE, 0xdeaddead,0xdeaddead, FALSE),
     51HOWTO ( 4,             0,  0,   8,  TRUE,  0, complain_overflow_signed,   MY(generic_reloc),"DISP8",    TRUE, 0x000000ff,0x000000ff, FALSE),
     52HOWTO ( 5,             0,  1,   16, TRUE,  0, complain_overflow_signed,   MY(generic_reloc),"DISP16",   TRUE, 0x0000ffff,0x0000ffff, FALSE),
     53HOWTO ( 6,             0,  2,   32, TRUE,  0, complain_overflow_signed,   MY(generic_reloc),"DISP32",   TRUE, 0xffffffff,0xffffffff, FALSE),
     54HOWTO ( 7,             0,  4,   64, TRUE,  0, complain_overflow_signed,   MY(generic_reloc),"DISP64",   TRUE, 0xfeedface,0xfeedface, FALSE),
     55HOWTO ( 8,             0,  2,    0, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"GOT_REL",  FALSE,         0,0x00000000, FALSE),
     56HOWTO ( 9,             0,  1,   16, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"BASE16",   FALSE,0xffffffff,0xffffffff, FALSE),
     57HOWTO (10,             0,  2,   32, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"BASE32",   FALSE,0xffffffff,0xffffffff, FALSE),
     58EMPTY_HOWTO (-1),
     59EMPTY_HOWTO (-1),
     60EMPTY_HOWTO (-1),
     61EMPTY_HOWTO (-1),
     62EMPTY_HOWTO (-1),
     63  HOWTO (16,           0,  2,    0, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"JMP_TABLE", FALSE,         0,0x00000000, FALSE),
     64EMPTY_HOWTO (-1),
     65EMPTY_HOWTO (-1),
     66EMPTY_HOWTO (-1),
     67EMPTY_HOWTO (-1),
     68EMPTY_HOWTO (-1),
     69EMPTY_HOWTO (-1),
     70EMPTY_HOWTO (-1),
     71EMPTY_HOWTO (-1),
     72EMPTY_HOWTO (-1),
     73EMPTY_HOWTO (-1),
     74EMPTY_HOWTO (-1),
     75EMPTY_HOWTO (-1),
     76EMPTY_HOWTO (-1),
     77EMPTY_HOWTO (-1),
     78EMPTY_HOWTO (-1),
     79  HOWTO (32,           0,  2,    0, FALSE, 0, complain_overflow_bitfield, MY(generic_reloc),"RELATIVE",  FALSE,         0,0x00000000, FALSE),
     80EMPTY_HOWTO (-1),
     81EMPTY_HOWTO (-1),
     82EMPTY_HOWTO (-1),
     83EMPTY_HOWTO (-1),
     84EMPTY_HOWTO (-1),
     85EMPTY_HOWTO (-1),
     86EMPTY_HOWTO (-1),
     87  HOWTO (40,           0,  2,    0, FALSE, 0, complain_overflow_bitfield,0,"BASEREL",   FALSE,         0,0x00000000, FALSE),
     88};
     89
     90
     91CONST struct aout_backend_data MY(backend_data) = {
    3892  0,                            /* zmagic contiguous */
    3993  0,                            /* text incl header */
     
    101155#endif
    102156
     157
    103158/*
    104159 * Finish up the reading of an a.out file header
    105160 */
    106 static const bfd_target *
     161const bfd_target *
    107162MY(object_p) (abfd)
    108163  bfd *abfd;
     
    135190  return target;
    136191}
     192
     193
     194reloc_howto_type *
     195MY(reloc_type_lookup) (abfd,code)
     196     bfd *abfd;
     197     bfd_reloc_code_real_type code;
     198{
     199#define STD(i, j)       case i: return &MY(howto_table_std)[j]
     200
     201  if (obj_reloc_entry_size (abfd) == RELOC_EXT_SIZE)
     202    return NAME(aout,reloc_type_lookup) (abfd, code);
     203
     204
     205  if (code == BFD_RELOC_CTOR)
     206    switch (bfd_get_arch_info (abfd)->bits_per_address)
     207      {
     208      case 32:
     209        code = BFD_RELOC_32;
     210        break;
     211      case 64:
     212        code = BFD_RELOC_64;
     213        break;
     214      }
     215
     216  /* std relocs.  */
     217  switch (code)
     218    {
     219      STD (BFD_RELOC_8, 0);
     220      STD (BFD_RELOC_16, 1);
     221      STD (BFD_RELOC_32, 2);
     222      STD (BFD_RELOC_8_PCREL, 4);
     223      STD (BFD_RELOC_16_PCREL, 5);
     224      STD (BFD_RELOC_32_PCREL, 6);
     225      STD (BFD_RELOC_16_BASEREL, 9);
     226      STD (BFD_RELOC_32_BASEREL, 10);
     227    default: return (reloc_howto_type *) NULL;
     228    }
     229}
     230
     231/* ELF relocs are against symbols.  If we are producing relocateable
     232   output, and the reloc is against an external symbol, and nothing
     233   has given us any additional addend, the resulting reloc will also
     234   be against the same symbol.  In such a case, we don't want to
     235   change anything about the way the reloc is handled, since it will
     236   all be done at final link time.  Rather than put special case code
     237   into bfd_perform_relocation, all the reloc types use this howto
     238   function.  It just short circuits the reloc if producing
     239   relocateable output against an external symbol.  */
     240
     241bfd_reloc_status_type
     242MY(generic_reloc) (abfd,
     243                   reloc_entry,
     244                   symbol,
     245                   data,
     246                   input_section,
     247                   output_bfd,
     248                   error_message)
     249     bfd *abfd ATTRIBUTE_UNUSED;
     250     arelent *reloc_entry;
     251     asymbol *symbol;
     252     PTR data ATTRIBUTE_UNUSED;
     253     asection *input_section;
     254     bfd *output_bfd;
     255     char **error_message ATTRIBUTE_UNUSED;
     256{
     257  if (output_bfd != (bfd *) NULL
     258      && (symbol->flags & BSF_SECTION_SYM) == 0
     259      && (! reloc_entry->howto->partial_inplace
     260          || reloc_entry->addend == 0))
     261    {
     262      reloc_entry->address += input_section->output_offset;
     263      return bfd_reloc_ok;
     264    }
     265
     266  return bfd_reloc_continue;
     267}
     268
Note: See TracChangeset for help on using the changeset viewer.