1999-05-03 09:29:11 +02:00
|
|
|
/* Support for 32-bit i386 NLM (NetWare Loadable Module)
|
2016-01-01 12:25:12 +01:00
|
|
|
Copyright (C) 1993-2016 Free Software Foundation, Inc.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-04-21 09:45:39 +02:00
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-04-21 09:45:39 +02:00
|
|
|
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
|
2007-07-03 16:26:43 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2005-04-21 09:45:39 +02:00
|
|
|
(at your option) any later version.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-04-21 09:45:39 +02:00
|
|
|
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.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2005-04-21 09:45:39 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2007-07-03 16:26:43 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
#include "sysdep.h"
|
2007-04-26 16:47:00 +02:00
|
|
|
#include "bfd.h"
|
1999-05-03 09:29:11 +02:00
|
|
|
#include "libbfd.h"
|
|
|
|
|
|
|
|
#define ARCH_SIZE 32
|
|
|
|
|
|
|
|
#include "nlm/i386-ext.h"
|
|
|
|
#define Nlm_External_Fixed_Header Nlm32_i386_External_Fixed_Header
|
|
|
|
|
|
|
|
#include "libnlm.h"
|
|
|
|
|
|
|
|
/* Adjust the reloc location by an absolute value. */
|
|
|
|
|
|
|
|
static reloc_howto_type nlm_i386_abs_howto =
|
2005-04-21 09:45:39 +02:00
|
|
|
HOWTO (0, /* Type. */
|
|
|
|
0, /* Rightshift. */
|
|
|
|
2, /* Size (0 = byte, 1 = short, 2 = long). */
|
|
|
|
32, /* Bitsize. */
|
|
|
|
FALSE, /* PC relative. */
|
|
|
|
0, /* Bitpos. */
|
|
|
|
complain_overflow_bitfield, /* Complain_on_overflow. */
|
|
|
|
0, /* Special_function. */
|
|
|
|
"32", /* Name. */
|
|
|
|
TRUE, /* Partial_inplace. */
|
|
|
|
0xffffffff, /* Source mask. */
|
|
|
|
0xffffffff, /* Dest mask. */
|
|
|
|
FALSE); /* PR rel_offset. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
/* Adjust the reloc location by a PC relative displacement. */
|
|
|
|
|
|
|
|
static reloc_howto_type nlm_i386_pcrel_howto =
|
2005-04-21 09:45:39 +02:00
|
|
|
HOWTO (1, /* Type. */
|
|
|
|
0, /* Rightshift. */
|
|
|
|
2, /* Size (0 = byte, 1 = short, 2 = long). */
|
|
|
|
32, /* Bitsize. */
|
|
|
|
TRUE, /* PC relative. */
|
|
|
|
0, /* Bitpos. */
|
|
|
|
complain_overflow_signed, /* Complain_on_overflow. */
|
|
|
|
0, /* Special_function. */
|
|
|
|
"DISP32", /* Name. */
|
|
|
|
TRUE, /* Partial_inplace. */
|
|
|
|
0xffffffff, /* Source mask. */
|
|
|
|
0xffffffff, /* Dest mask. */
|
|
|
|
TRUE); /* PR rel_offset. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
/* Read a NetWare i386 reloc. */
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
static bfd_boolean
|
2005-04-21 09:45:39 +02:00
|
|
|
nlm_i386_read_reloc (bfd *abfd,
|
|
|
|
nlmNAME (symbol_type) *sym,
|
|
|
|
asection **secp,
|
|
|
|
arelent *rel)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
bfd_byte temp[4];
|
|
|
|
bfd_vma val;
|
|
|
|
const char *name;
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
val = bfd_get_32 (abfd, temp);
|
|
|
|
|
|
|
|
/* The value is an offset into either the code or data segment.
|
|
|
|
This is the location which needs to be adjusted.
|
|
|
|
|
|
|
|
If this is a relocation fixup rather than an imported symbol (the
|
|
|
|
sym argument is NULL) then the high bit is 0 if the location
|
|
|
|
needs to be adjusted by the address of the data segment, or 1 if
|
|
|
|
the location needs to be adjusted by the address of the code
|
|
|
|
segment. If this is an imported symbol, then the high bit is 0
|
|
|
|
if the location is 0 if the location should be adjusted by the
|
|
|
|
offset to the symbol, or 1 if the location should adjusted by the
|
|
|
|
absolute value of the symbol.
|
|
|
|
|
|
|
|
The second most significant bit is 0 if the value is an offset
|
|
|
|
into the data segment, or 1 if the value is an offset into the
|
|
|
|
code segment.
|
|
|
|
|
|
|
|
All this translates fairly easily into a BFD reloc. */
|
|
|
|
|
|
|
|
if (sym == NULL)
|
|
|
|
{
|
|
|
|
if ((val & NLM_HIBIT) == 0)
|
|
|
|
name = NLM_INITIALIZED_DATA_NAME;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name = NLM_CODE_NAME;
|
|
|
|
val &=~ NLM_HIBIT;
|
|
|
|
}
|
|
|
|
rel->sym_ptr_ptr = bfd_get_section_by_name (abfd, name)->symbol_ptr_ptr;
|
|
|
|
rel->howto = &nlm_i386_abs_howto;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* In this case we do not need to set the sym_ptr_ptr field. */
|
|
|
|
rel->sym_ptr_ptr = NULL;
|
|
|
|
if ((val & NLM_HIBIT) == 0)
|
|
|
|
rel->howto = &nlm_i386_pcrel_howto;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rel->howto = &nlm_i386_abs_howto;
|
|
|
|
val &=~ NLM_HIBIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((val & (NLM_HIBIT >> 1)) == 0)
|
|
|
|
*secp = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*secp = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
|
|
|
|
val &=~ (NLM_HIBIT >> 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rel->address = val;
|
|
|
|
rel->addend = 0;
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write a NetWare i386 reloc. */
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
static bfd_boolean
|
2005-04-21 09:45:39 +02:00
|
|
|
nlm_i386_write_import (bfd * abfd, asection * sec, arelent * rel)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
asymbol *sym;
|
|
|
|
bfd_vma val;
|
|
|
|
bfd_byte temp[4];
|
|
|
|
|
|
|
|
/* NetWare only supports two kinds of relocs. We should check
|
|
|
|
special_function here, as well, but at the moment coff-i386
|
|
|
|
relocs uses a special_function which does not affect what we do
|
|
|
|
here. */
|
|
|
|
if (rel->addend != 0
|
|
|
|
|| rel->howto == NULL
|
|
|
|
|| rel->howto->rightshift != 0
|
|
|
|
|| rel->howto->size != 2
|
|
|
|
|| rel->howto->bitsize != 32
|
|
|
|
|| rel->howto->bitpos != 0
|
|
|
|
|| rel->howto->src_mask != 0xffffffff
|
|
|
|
|| rel->howto->dst_mask != 0xffffffff)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sym = *rel->sym_ptr_ptr;
|
|
|
|
|
|
|
|
/* The value we write out is the offset into the appropriate
|
|
|
|
segment. This offset is the section vma, adjusted by the vma of
|
|
|
|
the lowest section in that segment, plus the address of the
|
|
|
|
relocation. */
|
|
|
|
val = bfd_get_section_vma (abfd, sec) + rel->address;
|
|
|
|
|
|
|
|
/* The second most significant bit is 0 if the value is an offset
|
|
|
|
into the data segment, or 1 if the value is an offset into the
|
|
|
|
code segment. */
|
|
|
|
if (bfd_get_section_flags (abfd, sec) & SEC_CODE)
|
|
|
|
{
|
|
|
|
val -= nlm_get_text_low (abfd);
|
|
|
|
val |= NLM_HIBIT >> 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val -= nlm_get_data_low (abfd);
|
|
|
|
|
|
|
|
if (! bfd_is_und_section (bfd_get_section (sym)))
|
|
|
|
{
|
|
|
|
/* NetWare only supports absolute internal relocs. */
|
|
|
|
if (rel->howto->pc_relative)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The high bit is 1 if the reloc is against the code section, 0
|
|
|
|
if against the data section. */
|
|
|
|
if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
|
|
|
|
val |= NLM_HIBIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The high bit is 1 if this is an absolute reloc, 0 if it is PC
|
|
|
|
relative. */
|
|
|
|
if (! rel->howto->pc_relative)
|
|
|
|
val |= NLM_HIBIT;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* PC relative relocs on NetWare must be pcrel_offset. */
|
|
|
|
if (! rel->howto->pcrel_offset)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-12-12 22:25:54 +01:00
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
bfd_put_32 (abfd, val, temp);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2001-10-10 14:08:29 +02:00
|
|
|
/* I want to be able to use objcopy to turn an i386 a.out or COFF file
|
1999-05-03 09:29:11 +02:00
|
|
|
into a NetWare i386 module. That means that the relocs from the
|
|
|
|
source file have to be mapped into relocs that apply to the target
|
|
|
|
file. This function is called by nlm_set_section_contents to give
|
|
|
|
it a chance to rework the relocs.
|
|
|
|
|
|
|
|
This is actually a fairly general concept. However, this is not a
|
|
|
|
general implementation. */
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
static bfd_boolean
|
2005-04-21 09:45:39 +02:00
|
|
|
nlm_i386_mangle_relocs (bfd *abfd,
|
|
|
|
asection *sec,
|
2012-07-13 16:22:50 +02:00
|
|
|
const void * data,
|
2005-04-21 09:45:39 +02:00
|
|
|
bfd_vma offset,
|
|
|
|
bfd_size_type count)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
arelent **rel_ptr_ptr, **rel_end;
|
|
|
|
|
|
|
|
rel_ptr_ptr = sec->orelocation;
|
|
|
|
rel_end = rel_ptr_ptr + sec->reloc_count;
|
|
|
|
for (; rel_ptr_ptr < rel_end; rel_ptr_ptr++)
|
|
|
|
{
|
|
|
|
arelent *rel;
|
|
|
|
asymbol *sym;
|
|
|
|
bfd_vma addend;
|
|
|
|
|
|
|
|
rel = *rel_ptr_ptr;
|
|
|
|
sym = *rel->sym_ptr_ptr;
|
|
|
|
|
|
|
|
/* Note that no serious harm will ensue if we fail to change a
|
|
|
|
reloc. We will wind up failing in nlm_i386_write_import. */
|
|
|
|
|
|
|
|
/* Make sure this reloc is within the data we have. We only 4
|
|
|
|
byte relocs here, so we insist on having 4 bytes. */
|
|
|
|
if (rel->address < offset
|
|
|
|
|| rel->address + 4 > offset + count)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* NetWare doesn't support reloc addends, so we get rid of them
|
|
|
|
here by simply adding them into the object data. We handle
|
|
|
|
the symbol value, if any, the same way. */
|
|
|
|
addend = rel->addend + sym->value;
|
|
|
|
|
|
|
|
/* The value of a symbol is the offset into the section. If the
|
|
|
|
symbol is in the .bss segment, we need to include the size of
|
|
|
|
the data segment in the offset as well. Fortunately, we know
|
|
|
|
that at this point the size of the data section is in the NLM
|
|
|
|
header. */
|
|
|
|
if (((bfd_get_section_flags (abfd, bfd_get_section (sym))
|
|
|
|
& SEC_LOAD) == 0)
|
|
|
|
&& ((bfd_get_section_flags (abfd, bfd_get_section (sym))
|
|
|
|
& SEC_ALLOC) != 0))
|
|
|
|
addend += nlm_fixed_header (abfd)->dataImageSize;
|
|
|
|
|
|
|
|
if (addend != 0
|
|
|
|
&& rel->howto != NULL
|
|
|
|
&& rel->howto->rightshift == 0
|
|
|
|
&& rel->howto->size == 2
|
|
|
|
&& rel->howto->bitsize == 32
|
|
|
|
&& rel->howto->bitpos == 0
|
|
|
|
&& rel->howto->src_mask == 0xffffffff
|
|
|
|
&& rel->howto->dst_mask == 0xffffffff)
|
|
|
|
{
|
|
|
|
bfd_vma val;
|
|
|
|
|
|
|
|
val = bfd_get_32 (abfd, (bfd_byte *) data + rel->address - offset);
|
|
|
|
val += addend;
|
|
|
|
bfd_put_32 (abfd, val, (bfd_byte *) data + rel->address - offset);
|
|
|
|
rel->addend = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NetWare uses a reloc with pcrel_offset set. We adjust
|
|
|
|
pc_relative relocs accordingly. We are going to change the
|
|
|
|
howto field, so we can only do this if the current one is
|
|
|
|
compatible. We should check special_function here, but at
|
|
|
|
the moment coff-i386 uses a special_function which does not
|
|
|
|
affect what we are doing here. */
|
|
|
|
if (rel->howto != NULL
|
|
|
|
&& rel->howto->pc_relative
|
|
|
|
&& ! rel->howto->pcrel_offset
|
|
|
|
&& rel->howto->rightshift == 0
|
|
|
|
&& rel->howto->size == 2
|
|
|
|
&& rel->howto->bitsize == 32
|
|
|
|
&& rel->howto->bitpos == 0
|
|
|
|
&& rel->howto->src_mask == 0xffffffff
|
|
|
|
&& rel->howto->dst_mask == 0xffffffff)
|
|
|
|
{
|
|
|
|
bfd_vma val;
|
|
|
|
|
|
|
|
/* When pcrel_offset is not set, it means that the negative
|
|
|
|
of the address of the memory location is stored in the
|
|
|
|
memory location. We must add it back in. */
|
|
|
|
val = bfd_get_32 (abfd, (bfd_byte *) data + rel->address - offset);
|
|
|
|
val += rel->address;
|
|
|
|
bfd_put_32 (abfd, val, (bfd_byte *) data + rel->address - offset);
|
|
|
|
|
|
|
|
rel->howto = &nlm_i386_pcrel_howto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2005-04-21 09:45:39 +02:00
|
|
|
/* Read a NetWare i386 import record. */
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
static bfd_boolean
|
2005-04-21 09:45:39 +02:00
|
|
|
nlm_i386_read_import (bfd * abfd, nlmNAME (symbol_type) * sym)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2005-04-21 09:45:39 +02:00
|
|
|
struct nlm_relent *nlm_relocs; /* Relocation records for symbol. */
|
|
|
|
bfd_size_type rcount; /* Number of relocs. */
|
|
|
|
bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Temporary 32-bit value. */
|
|
|
|
unsigned char symlength; /* Length of symbol name. */
|
1999-05-03 09:29:11 +02:00
|
|
|
char *name;
|
|
|
|
|
2005-04-21 09:45:39 +02:00
|
|
|
if (bfd_bread (& symlength, (bfd_size_type) sizeof (symlength), abfd)
|
1999-05-03 09:29:11 +02:00
|
|
|
!= sizeof (symlength))
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
sym -> symbol.the_bfd = abfd;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
|
1999-05-03 09:29:11 +02:00
|
|
|
if (name == NULL)
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
name[symlength] = '\0';
|
|
|
|
sym -> symbol.name = name;
|
|
|
|
sym -> symbol.flags = 0;
|
|
|
|
sym -> symbol.value = 0;
|
|
|
|
sym -> symbol.section = bfd_und_section_ptr;
|
2005-04-21 09:45:39 +02:00
|
|
|
if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
rcount = H_GET_32 (abfd, temp);
|
2005-04-21 09:45:39 +02:00
|
|
|
nlm_relocs = bfd_alloc (abfd, rcount * sizeof (struct nlm_relent));
|
1999-05-03 09:29:11 +02:00
|
|
|
if (!nlm_relocs)
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
sym -> relocs = nlm_relocs;
|
|
|
|
sym -> rcnt = 0;
|
|
|
|
while (sym -> rcnt < rcount)
|
|
|
|
{
|
|
|
|
asection *section;
|
2000-12-12 22:25:54 +01:00
|
|
|
|
2002-06-25 08:21:54 +02:00
|
|
|
if (! nlm_i386_read_reloc (abfd, sym, §ion, &nlm_relocs -> reloc))
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
nlm_relocs -> section = section;
|
|
|
|
nlm_relocs++;
|
|
|
|
sym -> rcnt++;
|
|
|
|
}
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out an external reference. */
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
static bfd_boolean
|
2005-04-21 09:45:39 +02:00
|
|
|
nlm_i386_write_external (bfd *abfd,
|
|
|
|
bfd_size_type count,
|
|
|
|
asymbol *sym,
|
|
|
|
struct reloc_and_sec *relocs)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
bfd_byte len;
|
|
|
|
unsigned char temp[NLM_TARGET_LONG_SIZE];
|
|
|
|
|
|
|
|
len = strlen (sym->name);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
|
|
|
|
!= sizeof (bfd_byte))
|
|
|
|
|| bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
bfd_put_32 (abfd, count, temp);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
2005-04-21 09:45:39 +02:00
|
|
|
if (! nlm_i386_write_import (abfd, relocs[i].sec, relocs[i].rel))
|
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "nlmswap.h"
|
|
|
|
|
|
|
|
static const struct nlm_backend_data nlm32_i386_backend =
|
|
|
|
{
|
|
|
|
"NetWare Loadable Module\032",
|
|
|
|
sizeof (Nlm32_i386_External_Fixed_Header),
|
2005-04-21 09:45:39 +02:00
|
|
|
0, /* Optional_prefix_size. */
|
1999-05-03 09:29:11 +02:00
|
|
|
bfd_arch_i386,
|
|
|
|
0,
|
2002-11-30 09:39:46 +01:00
|
|
|
FALSE,
|
2005-04-21 09:45:39 +02:00
|
|
|
0, /* Backend_object_p. */
|
|
|
|
0, /* Write_prefix_func. */
|
1999-05-03 09:29:11 +02:00
|
|
|
nlm_i386_read_reloc,
|
|
|
|
nlm_i386_mangle_relocs,
|
|
|
|
nlm_i386_read_import,
|
|
|
|
nlm_i386_write_import,
|
2005-04-21 09:45:39 +02:00
|
|
|
0, /* Set_public_section. */
|
|
|
|
0, /* Set_public_offset. */
|
1999-05-03 09:29:11 +02:00
|
|
|
nlm_swap_fixed_header_in,
|
|
|
|
nlm_swap_fixed_header_out,
|
|
|
|
nlm_i386_write_external,
|
2005-04-21 09:45:39 +02:00
|
|
|
0, /* Write_export. */
|
1999-05-03 09:29:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#define TARGET_LITTLE_NAME "nlm32-i386"
|
bfd target vector rationalisation
This renames the bfd targets to <cpu>_<format>_<other>_<endian>_vec.
So for example, bfd_elf32_ntradlittlemips_vec becomes
mips_elf32_ntrad_le_vec and hp300bsd_vec becomes m68k_aout_hp300bsd_vec.
bfd/
* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-ns32k.c,
* aout-sparcle.c, * aout0.c, * aoutx.h, * armnetbsd.c, * bout.c,
* cf-i386lynx.c, * cf-sparclynx.c, * cisco-core.c, * coff-alpha.c,
* coff-apollo.c, * coff-arm.c, * coff-aux.c, * coff-go32.c,
* coff-h8300.c, * coff-h8500.c, * coff-i386.c, * coff-i860.c,
* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mips.c,
* coff-rs6000.c, * coff-sh.c, * coff-sparc.c, * coff-stgo32.c,
* coff-svm68k.c, * coff-tic80.c, * coff-u68k.c, * coff-w65.c,
* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
* coff64-rs6000.c, * config.bfd, * configure.com, * configure.in,
* demo64.c, * elf-m10200.c, * elf-m10300.c, * elf32-am33lin.c,
* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c,
* elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c,
* elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c,
* elf32-fr30.c, * elf32-frv.c, * elf32-gen.c, * elf32-h8300.c,
* elf32-hppa.c, * elf32-i370.c, * elf32-i386.c, * elf32-i860.c,
* elf32-i960.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c,
* elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c,
* elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c, * elf32-mep.c,
* elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c,
* elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nios2.c,
* elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-rl78.c,
* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-sh-symbian.c,
* elf32-sh.c, * elf32-sh64.c, * elf32-sparc.c, * elf32-spu.c,
* elf32-tic6x.c, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-v850.c,
* elf32-vax.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c,
* elf32-xtensa.c, * elf64-alpha.c, * elf64-gen.c, * elf64-hppa.c,
* elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-ppc.c,
* elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c, * elf64-tilegx.c,
* elf64-x86-64.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
* epoc-pe-arm.c, * epoc-pei-arm.c, * hp300bsd.c, * hp300hpux.c,
* hppabsd-core.c, * hpux-core.c, * i386aout.c, * i386bsd.c,
* i386dynix.c, * i386freebsd.c, * i386linux.c, * i386lynx.c,
* i386mach3.c, * i386msdos.c, * i386netbsd.c, * i386os9k.c,
* irix-core.c, * m68k4knetbsd.c, * m68klinux.c, * m68knetbsd.c,
* m88kmach3.c, * m88kopenbsd.c, * mach-o-i386.c, * mach-o-x86-64.c,
* makefile.vms, * mipsbsd.c, * mmo.c, * netbsd-core.c, * newsos3.c,
* nlm32-alpha.c, * nlm32-i386.c, * nlm32-ppc.c, * nlm32-sparc.c,
* ns32knetbsd.c, * osf-core.c, * pc532-mach.c, * pe-arm-wince.c,
* pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-mips.c, * pe-ppc.c,
* pe-sh.c, * pe-x86_64.c, * pei-arm-wince.c, * pei-arm.c,
* pei-i386.c, * pei-ia64.c, * pei-mcore.c, * pei-mips.c, * pei-ppc.c,
* pei-sh.c, * pei-x86_64.c, * ppcboot.c, * ptrace-core.c, * riscix.c,
* sco5-core.c, * som.c, * sparclinux.c, * sparclynx.c,
* sparcnetbsd.c, * sunos.c, * targets.c, * trad-core.c,
* vax1knetbsd.c, * vaxbsd.c, * vaxnetbsd.c, * versados.c,
* vms-alpha.c, * vms-lib.c: Rename bfd targets to
<cpu>_<format>_<other>_<endian>_vec. Adjust associated MY macros
on aout targets.
* configure: Regenerate.
binutils/
* emul_aix.c: Update bfd target vector naming.
* testsuite/binutils-all/objcopy.exp: Likewise.
ld/
* emultempl/metagelf.em: Update bfd target vector naming.
* emultempl/nios2elf.em: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/tic6xdsbt.em: Likewise.
2014-05-02 12:39:40 +02:00
|
|
|
#define TARGET_LITTLE_SYM i386_nlm32_vec
|
2005-04-21 09:45:39 +02:00
|
|
|
#define TARGET_BACKEND_DATA & nlm32_i386_backend
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
#include "nlm-target.h"
|