1999-05-03 09:29:11 +02:00
|
|
|
|
/* opncls.c -- open and close a BFD.
|
2001-03-08 22:04:02 +01:00
|
|
|
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
|
2005-02-20 15:59:07 +01:00
|
|
|
|
2001, 2002, 2003, 2004, 2005
|
1999-05-03 09:29:11 +02:00
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Written by Cygnus Support.
|
|
|
|
|
|
2002-04-15 16:32:28 +02:00
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-04-15 16:32:28 +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
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-04-15 16:32:28 +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
|
|
|
|
|
2002-04-15 16:32:28 +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
|
2005-05-04 17:53:43 +02:00
|
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
#include "bfd.h"
|
|
|
|
|
#include "sysdep.h"
|
|
|
|
|
#include "objalloc.h"
|
|
|
|
|
#include "libbfd.h"
|
2003-01-31 11:04:16 +01:00
|
|
|
|
#include "libiberty.h"
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
#ifndef S_IXUSR
|
|
|
|
|
#define S_IXUSR 0100 /* Execute by owner. */
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef S_IXGRP
|
|
|
|
|
#define S_IXGRP 0010 /* Execute by group. */
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef S_IXOTH
|
|
|
|
|
#define S_IXOTH 0001 /* Execute by others. */
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-01-28 00:40:39 +01:00
|
|
|
|
/* Counter used to initialize the bfd identifier. */
|
|
|
|
|
|
|
|
|
|
static unsigned int _bfd_id_counter = 0;
|
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
/* fdopen is a loser -- we should use stdio exclusively. Unfortunately
|
|
|
|
|
if we do that we can't use fcntl. */
|
|
|
|
|
|
|
|
|
|
/* Return a new BFD. All BFD's are allocated through this routine. */
|
|
|
|
|
|
|
|
|
|
bfd *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
_bfd_new_bfd (void)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
bfd *nbfd;
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
nbfd = bfd_zmalloc (sizeof (bfd));
|
1999-05-03 09:29:11 +02:00
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2003-01-28 00:40:39 +01:00
|
|
|
|
nbfd->id = _bfd_id_counter++;
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
nbfd->memory = objalloc_create ();
|
1999-05-03 09:29:11 +02:00
|
|
|
|
if (nbfd->memory == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_no_memory);
|
2001-12-17 01:40:53 +01:00
|
|
|
|
free (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nbfd->arch_info = &bfd_default_arch_struct;
|
|
|
|
|
|
|
|
|
|
nbfd->direction = no_direction;
|
|
|
|
|
nbfd->iostream = NULL;
|
|
|
|
|
nbfd->where = 0;
|
2004-01-21 12:17:53 +01:00
|
|
|
|
if (!bfd_hash_table_init_n (& nbfd->section_htab, bfd_section_hash_newfunc,
|
2002-10-06 11:03:06 +02:00
|
|
|
|
251))
|
2001-12-17 01:40:53 +01:00
|
|
|
|
{
|
|
|
|
|
free (nbfd);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-06-29 12:06:40 +02:00
|
|
|
|
nbfd->sections = NULL;
|
2005-05-03 03:05:03 +02:00
|
|
|
|
nbfd->section_last = NULL;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->format = bfd_unknown;
|
2003-06-29 12:06:40 +02:00
|
|
|
|
nbfd->my_archive = NULL;
|
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
|
|
|
|
nbfd->origin = 0;
|
2002-11-30 09:39:46 +01:00
|
|
|
|
nbfd->opened_once = FALSE;
|
|
|
|
|
nbfd->output_has_begun = FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->section_count = 0;
|
2003-06-29 12:06:40 +02:00
|
|
|
|
nbfd->usrdata = NULL;
|
2002-11-30 09:39:46 +01:00
|
|
|
|
nbfd->cacheable = FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->flags = BFD_NO_FLAGS;
|
2002-11-30 09:39:46 +01:00
|
|
|
|
nbfd->mtime_set = FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Allocate a new BFD as a member of archive OBFD. */
|
|
|
|
|
|
|
|
|
|
bfd *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
_bfd_new_bfd_contained_in (bfd *obfd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
bfd *nbfd;
|
|
|
|
|
|
|
|
|
|
nbfd = _bfd_new_bfd ();
|
2002-05-04 03:31:08 +02:00
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->xvec = obfd->xvec;
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* opncls.c (_bfd_new_bfd_contained_in): Copy "iovec".
(struct opncls, opncls_btell, opncls_bseek, opncls_bread)
(opncls_bwrite, opncls_bclose, opncls_bflush)
(opncls_bstat, opncls_iovec, bfd_openr_iovec): Implement a
bfd iovec that uses function callbacks.
(bfd_close): Use the iovec's bclose.
* cache.c (cache_btell, cache_bseek, cache_bread, cache_bwrite)
(cache_bclose, cache_bflush, cache_bstat)
(cache_iovec): New functions and global variable, implement a
cache "iovec", where applicable set bfd_error.
(bfd_cache_init, bfd_cache_close): Set/test the bfd's iovec.
* bfdio.c (struct bfd_iovec): Define.
(real_read): Delete function.
(bfd_bread, bfd_bread, bfd_bwrite, bfd_tell, bfd_flush, bfd_stat)
(bfd_seek, bfd_get_mtime, bfd_get_size): Use the bfd's "iovec",
assume that bread and bwrite set bfd_error.
* bfd.c (struct bfd): Add "iovec", update comments.
* bfd-in2.h, libbfd.h: Re-generate.
2004-04-21 19:05:12 +02:00
|
|
|
|
nbfd->iovec = obfd->iovec;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->my_archive = obfd;
|
|
|
|
|
nbfd->direction = read_direction;
|
|
|
|
|
nbfd->target_defaulted = obfd->target_defaulted;
|
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
|
/* Delete a BFD. */
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-29 12:06:40 +02:00
|
|
|
|
_bfd_delete_bfd (bfd *abfd)
|
2001-12-17 01:40:53 +01:00
|
|
|
|
{
|
|
|
|
|
bfd_hash_table_free (&abfd->section_htab);
|
|
|
|
|
objalloc_free ((struct objalloc *) abfd->memory);
|
|
|
|
|
free (abfd);
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
/*
|
|
|
|
|
SECTION
|
|
|
|
|
Opening and closing BFDs
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
2005-06-08 00:53:32 +02:00
|
|
|
|
bfd_fopen
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2005-06-08 00:53:32 +02:00
|
|
|
|
bfd *bfd_fopen (const char *filename, const char *target,
|
|
|
|
|
const char *mode, int fd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
2005-06-08 00:53:32 +02:00
|
|
|
|
Open the file @var{filename} with the target @var{target}.
|
|
|
|
|
Return a pointer to the created BFD. If @var{fd} is not -1,
|
|
|
|
|
then <<fdopen>> is used to open the file; otherwise, <<fopen>>
|
|
|
|
|
is used. @var{mode} is passed directly to <<fopen>> or
|
|
|
|
|
<<fdopen>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
Calls <<bfd_find_target>>, so @var{target} is interpreted as by
|
|
|
|
|
that function.
|
|
|
|
|
|
2005-06-09 09:30:19 +02:00
|
|
|
|
The new BFD is marked as cacheable iff @var{fd} is -1.
|
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
If <<NULL>> is returned then an error has occured. Possible errors
|
2002-10-06 11:03:06 +02:00
|
|
|
|
are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or
|
|
|
|
|
<<system_call>> error.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd *
|
2005-06-08 00:53:32 +02:00
|
|
|
|
bfd_fopen (const char *filename, const char *target, const char *mode, int fd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
bfd *nbfd;
|
|
|
|
|
const bfd_target *target_vec;
|
|
|
|
|
|
|
|
|
|
nbfd = _bfd_new_bfd ();
|
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
target_vec = bfd_find_target (target, nbfd);
|
|
|
|
|
if (target_vec == NULL)
|
|
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-06-08 00:53:32 +02:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_FDOPEN
|
|
|
|
|
if (fd != -1)
|
|
|
|
|
nbfd->iostream = fdopen (fd, mode);
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
nbfd->iostream = fopen (filename, mode);
|
|
|
|
|
if (nbfd->iostream == NULL)
|
|
|
|
|
{
|
2005-06-08 05:16:48 +02:00
|
|
|
|
bfd_set_error (bfd_error_system_call);
|
2005-06-08 00:53:32 +02:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2005-06-08 00:53:32 +02:00
|
|
|
|
/* OK, put everything where it belongs. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->filename = filename;
|
|
|
|
|
|
2005-06-08 00:53:32 +02:00
|
|
|
|
/* Figure out whether the user is opening the file for reading,
|
|
|
|
|
writing, or both, by looking at the MODE argument. */
|
|
|
|
|
if ((mode[0] == 'r' || mode[0] == 'w' || mode[0] == 'a')
|
|
|
|
|
&& mode[1] == '+')
|
|
|
|
|
nbfd->direction = both_direction;
|
|
|
|
|
else if (mode[0] == 'r')
|
|
|
|
|
nbfd->direction = read_direction;
|
|
|
|
|
else
|
|
|
|
|
nbfd->direction = write_direction;
|
|
|
|
|
|
|
|
|
|
if (! bfd_cache_init (nbfd))
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2005-06-08 00:53:32 +02:00
|
|
|
|
nbfd->opened_once = TRUE;
|
2005-06-09 09:30:19 +02:00
|
|
|
|
/* If we opened the file by name, mark it cacheable; we can close it
|
|
|
|
|
and reopen it later. However, if a file descriptor was provided,
|
|
|
|
|
then it may have been opened with special flags that make it
|
|
|
|
|
unsafe to close and reopen the file. */
|
|
|
|
|
if (fd == -1)
|
|
|
|
|
bfd_set_cacheable (nbfd, TRUE);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-08 00:53:32 +02:00
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_openr
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
|
bfd *bfd_openr (const char *filename, const char *target);
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Open the file @var{filename} (using <<fopen>>) with the target
|
|
|
|
|
@var{target}. Return a pointer to the created BFD.
|
|
|
|
|
|
|
|
|
|
Calls <<bfd_find_target>>, so @var{target} is interpreted as by
|
|
|
|
|
that function.
|
|
|
|
|
|
|
|
|
|
If <<NULL>> is returned then an error has occured. Possible errors
|
|
|
|
|
are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or
|
|
|
|
|
<<system_call>> error.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd *
|
|
|
|
|
bfd_openr (const char *filename, const char *target)
|
|
|
|
|
{
|
|
|
|
|
return bfd_fopen (filename, target, FOPEN_RB, -1);
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
/* Don't try to `optimize' this function:
|
|
|
|
|
|
|
|
|
|
o - We lock using stack space so that interrupting the locking
|
|
|
|
|
won't cause a storage leak.
|
|
|
|
|
o - We open the file stream last, since we don't want to have to
|
|
|
|
|
close it if anything goes wrong. Closing the stream means closing
|
2002-04-15 16:32:28 +02:00
|
|
|
|
the file descriptor too, even though we didn't open it. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
2002-10-06 11:03:06 +02:00
|
|
|
|
bfd_fdopenr
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
2002-10-06 11:03:06 +02:00
|
|
|
|
<<bfd_fdopenr>> is to <<bfd_fopenr>> much like <<fdopen>> is to
|
|
|
|
|
<<fopen>>. It opens a BFD on a file already described by the
|
|
|
|
|
@var{fd} supplied.
|
|
|
|
|
|
|
|
|
|
When the file is later <<bfd_close>>d, the file descriptor will
|
|
|
|
|
be closed. If the caller desires that this file descriptor be
|
|
|
|
|
cached by BFD (opened as needed, closed as needed to free
|
|
|
|
|
descriptors for other opens), with the supplied @var{fd} used as
|
|
|
|
|
an initial file descriptor (but subject to closure at any time),
|
|
|
|
|
call bfd_set_cacheable(bfd, 1) on the returned BFD. The default
|
2003-11-30 19:40:41 +01:00
|
|
|
|
is to assume no caching; the file descriptor will remain open
|
2002-10-06 11:03:06 +02:00
|
|
|
|
until <<bfd_close>>, and will not be affected by BFD operations
|
|
|
|
|
on other files.
|
|
|
|
|
|
|
|
|
|
Possible errors are <<bfd_error_no_memory>>,
|
|
|
|
|
<<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_fdopenr (const char *filename, const char *target, int fd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2005-06-08 00:53:32 +02:00
|
|
|
|
const char *mode;
|
|
|
|
|
#if defined(HAVE_FCNTL) && defined(F_GETFL)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
int fdflags;
|
2005-06-08 00:53:32 +02:00
|
|
|
|
#endif
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
#if ! defined(HAVE_FCNTL) || ! defined(F_GETFL)
|
2005-06-08 00:53:32 +02:00
|
|
|
|
mode = FOPEN_RUB; /* Assume full access. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
#else
|
|
|
|
|
fdflags = fcntl (fd, F_GETFL, NULL);
|
2002-06-17 04:33:42 +02:00
|
|
|
|
if (fdflags == -1)
|
2005-06-08 05:51:32 +02:00
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_system_call);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-04-15 16:32:28 +02:00
|
|
|
|
/* (O_ACCMODE) parens are to avoid Ultrix header file bug. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
switch (fdflags & (O_ACCMODE))
|
|
|
|
|
{
|
2005-06-08 02:00:05 +02:00
|
|
|
|
case O_RDONLY: mode = FOPEN_RB; break;
|
|
|
|
|
case O_WRONLY: mode = FOPEN_RUB; break;
|
|
|
|
|
case O_RDWR: mode = FOPEN_RUB; break;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
default: abort ();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-06-08 00:53:32 +02:00
|
|
|
|
return bfd_fopen (filename, target, mode, fd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_openstreamr
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd *bfd_openstreamr (const char *, const char *, void *);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
|
|
Open a BFD for read access on an existing stdio stream. When
|
|
|
|
|
the BFD is passed to <<bfd_close>>, the stream will be closed.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_openstreamr (const char *filename, const char *target, void *streamarg)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2003-06-29 12:06:40 +02:00
|
|
|
|
FILE *stream = streamarg;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
bfd *nbfd;
|
|
|
|
|
const bfd_target *target_vec;
|
|
|
|
|
|
|
|
|
|
nbfd = _bfd_new_bfd ();
|
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
target_vec = bfd_find_target (target, nbfd);
|
|
|
|
|
if (target_vec == NULL)
|
|
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
nbfd->iostream = stream;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd->filename = filename;
|
|
|
|
|
nbfd->direction = read_direction;
|
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
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
if (! bfd_cache_init (nbfd))
|
|
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* opncls.c (_bfd_new_bfd_contained_in): Copy "iovec".
(struct opncls, opncls_btell, opncls_bseek, opncls_bread)
(opncls_bwrite, opncls_bclose, opncls_bflush)
(opncls_bstat, opncls_iovec, bfd_openr_iovec): Implement a
bfd iovec that uses function callbacks.
(bfd_close): Use the iovec's bclose.
* cache.c (cache_btell, cache_bseek, cache_bread, cache_bwrite)
(cache_bclose, cache_bflush, cache_bstat)
(cache_iovec): New functions and global variable, implement a
cache "iovec", where applicable set bfd_error.
(bfd_cache_init, bfd_cache_close): Set/test the bfd's iovec.
* bfdio.c (struct bfd_iovec): Define.
(real_read): Delete function.
(bfd_bread, bfd_bread, bfd_bwrite, bfd_tell, bfd_flush, bfd_stat)
(bfd_seek, bfd_get_mtime, bfd_get_size): Use the bfd's "iovec",
assume that bread and bwrite set bfd_error.
* bfd.c (struct bfd): Add "iovec", update comments.
* bfd-in2.h, libbfd.h: Re-generate.
2004-04-21 19:05:12 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_openr_iovec
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
|
bfd *bfd_openr_iovec (const char *filename, const char *target,
|
|
|
|
|
void *(*open) (struct bfd *nbfd,
|
|
|
|
|
void *open_closure),
|
|
|
|
|
void *open_closure,
|
|
|
|
|
file_ptr (*pread) (struct bfd *nbfd,
|
|
|
|
|
void *stream,
|
|
|
|
|
void *buf,
|
|
|
|
|
file_ptr nbytes,
|
|
|
|
|
file_ptr offset),
|
|
|
|
|
int (*close) (struct bfd *nbfd,
|
|
|
|
|
void *stream));
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
|
|
Create and return a BFD backed by a read-only @var{stream}.
|
|
|
|
|
The @var{stream} is created using @var{open}, accessed using
|
|
|
|
|
@var{pread} and destroyed using @var{close}.
|
|
|
|
|
|
|
|
|
|
Calls <<bfd_find_target>>, so @var{target} is interpreted as by
|
|
|
|
|
that function.
|
|
|
|
|
|
|
|
|
|
Calls @var{open} (which can call <<bfd_zalloc>> and
|
|
|
|
|
<<bfd_get_filename>>) to obtain the read-only stream backing
|
|
|
|
|
the BFD. @var{open} either succeeds returning the
|
|
|
|
|
non-<<NULL>> @var{stream}, or fails returning <<NULL>>
|
|
|
|
|
(setting <<bfd_error>>).
|
|
|
|
|
|
|
|
|
|
Calls @var{pread} to request @var{nbytes} of data from
|
|
|
|
|
@var{stream} starting at @var{offset} (e.g., via a call to
|
|
|
|
|
<<bfd_read>>). @var{pread} either succeeds returning the
|
|
|
|
|
number of bytes read (which can be less than @var{nbytes} when
|
|
|
|
|
end-of-file), or fails returning -1 (setting <<bfd_error>>).
|
|
|
|
|
|
|
|
|
|
Calls @var{close} when the BFD is later closed using
|
|
|
|
|
<<bfd_close>>. @var{close} either succeeds returning 0, or
|
|
|
|
|
fails returning -1 (setting <<bfd_error>>).
|
|
|
|
|
|
|
|
|
|
If <<bfd_openr_iovec>> returns <<NULL>> then an error has
|
|
|
|
|
occurred. Possible errors are <<bfd_error_no_memory>>,
|
|
|
|
|
<<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct opncls
|
|
|
|
|
{
|
|
|
|
|
void *stream;
|
|
|
|
|
file_ptr (*pread) (struct bfd *abfd, void *stream, void *buf,
|
|
|
|
|
file_ptr nbytes, file_ptr offset);
|
|
|
|
|
int (*close) (struct bfd *abfd, void *stream);
|
|
|
|
|
file_ptr where;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static file_ptr
|
|
|
|
|
opncls_btell (struct bfd *abfd)
|
|
|
|
|
{
|
|
|
|
|
struct opncls *vec = abfd->iostream;
|
|
|
|
|
return vec->where;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
opncls_bseek (struct bfd *abfd, file_ptr offset, int whence)
|
|
|
|
|
{
|
|
|
|
|
struct opncls *vec = abfd->iostream;
|
|
|
|
|
switch (whence)
|
|
|
|
|
{
|
|
|
|
|
case SEEK_SET: vec->where = offset; break;
|
|
|
|
|
case SEEK_CUR: vec->where += offset; break;
|
|
|
|
|
case SEEK_END: return -1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static file_ptr
|
|
|
|
|
opncls_bread (struct bfd *abfd, void *buf, file_ptr nbytes)
|
|
|
|
|
{
|
|
|
|
|
struct opncls *vec = abfd->iostream;
|
2005-03-07 11:32:38 +01:00
|
|
|
|
file_ptr nread = (vec->pread) (abfd, vec->stream, buf, nbytes, vec->where);
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* opncls.c (_bfd_new_bfd_contained_in): Copy "iovec".
(struct opncls, opncls_btell, opncls_bseek, opncls_bread)
(opncls_bwrite, opncls_bclose, opncls_bflush)
(opncls_bstat, opncls_iovec, bfd_openr_iovec): Implement a
bfd iovec that uses function callbacks.
(bfd_close): Use the iovec's bclose.
* cache.c (cache_btell, cache_bseek, cache_bread, cache_bwrite)
(cache_bclose, cache_bflush, cache_bstat)
(cache_iovec): New functions and global variable, implement a
cache "iovec", where applicable set bfd_error.
(bfd_cache_init, bfd_cache_close): Set/test the bfd's iovec.
* bfdio.c (struct bfd_iovec): Define.
(real_read): Delete function.
(bfd_bread, bfd_bread, bfd_bwrite, bfd_tell, bfd_flush, bfd_stat)
(bfd_seek, bfd_get_mtime, bfd_get_size): Use the bfd's "iovec",
assume that bread and bwrite set bfd_error.
* bfd.c (struct bfd): Add "iovec", update comments.
* bfd-in2.h, libbfd.h: Re-generate.
2004-04-21 19:05:12 +02:00
|
|
|
|
if (nread < 0)
|
|
|
|
|
return nread;
|
|
|
|
|
vec->where += nread;
|
|
|
|
|
return nread;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static file_ptr
|
|
|
|
|
opncls_bwrite (struct bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
|
const void *where ATTRIBUTE_UNUSED,
|
|
|
|
|
file_ptr nbytes ATTRIBUTE_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
opncls_bclose (struct bfd *abfd)
|
|
|
|
|
{
|
|
|
|
|
struct opncls *vec = abfd->iostream;
|
|
|
|
|
/* Since the VEC's memory is bound to the bfd deleting the bfd will
|
|
|
|
|
free it. */
|
|
|
|
|
int status = 0;
|
|
|
|
|
if (vec->close != NULL)
|
2005-03-07 11:32:38 +01:00
|
|
|
|
status = (vec->close) (abfd, vec->stream);
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* opncls.c (_bfd_new_bfd_contained_in): Copy "iovec".
(struct opncls, opncls_btell, opncls_bseek, opncls_bread)
(opncls_bwrite, opncls_bclose, opncls_bflush)
(opncls_bstat, opncls_iovec, bfd_openr_iovec): Implement a
bfd iovec that uses function callbacks.
(bfd_close): Use the iovec's bclose.
* cache.c (cache_btell, cache_bseek, cache_bread, cache_bwrite)
(cache_bclose, cache_bflush, cache_bstat)
(cache_iovec): New functions and global variable, implement a
cache "iovec", where applicable set bfd_error.
(bfd_cache_init, bfd_cache_close): Set/test the bfd's iovec.
* bfdio.c (struct bfd_iovec): Define.
(real_read): Delete function.
(bfd_bread, bfd_bread, bfd_bwrite, bfd_tell, bfd_flush, bfd_stat)
(bfd_seek, bfd_get_mtime, bfd_get_size): Use the bfd's "iovec",
assume that bread and bwrite set bfd_error.
* bfd.c (struct bfd): Add "iovec", update comments.
* bfd-in2.h, libbfd.h: Re-generate.
2004-04-21 19:05:12 +02:00
|
|
|
|
abfd->iostream = NULL;
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
opncls_bflush (struct bfd *abfd ATTRIBUTE_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
opncls_bstat (struct bfd *abfd ATTRIBUTE_UNUSED, struct stat *sb)
|
|
|
|
|
{
|
|
|
|
|
memset (sb, 0, sizeof (*sb));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct bfd_iovec opncls_iovec = {
|
|
|
|
|
&opncls_bread, &opncls_bwrite, &opncls_btell, &opncls_bseek,
|
|
|
|
|
&opncls_bclose, &opncls_bflush, &opncls_bstat
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bfd *
|
|
|
|
|
bfd_openr_iovec (const char *filename, const char *target,
|
|
|
|
|
void *(*open) (struct bfd *nbfd,
|
|
|
|
|
void *open_closure),
|
|
|
|
|
void *open_closure,
|
|
|
|
|
file_ptr (*pread) (struct bfd *abfd,
|
|
|
|
|
void *stream,
|
|
|
|
|
void *buf,
|
|
|
|
|
file_ptr nbytes,
|
|
|
|
|
file_ptr offset),
|
|
|
|
|
int (*close) (struct bfd *nbfd,
|
|
|
|
|
void *stream))
|
|
|
|
|
{
|
|
|
|
|
bfd *nbfd;
|
|
|
|
|
const bfd_target *target_vec;
|
|
|
|
|
struct opncls *vec;
|
|
|
|
|
void *stream;
|
|
|
|
|
|
|
|
|
|
nbfd = _bfd_new_bfd ();
|
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
target_vec = bfd_find_target (target, nbfd);
|
|
|
|
|
if (target_vec == NULL)
|
|
|
|
|
{
|
|
|
|
|
_bfd_delete_bfd (nbfd);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nbfd->filename = filename;
|
|
|
|
|
nbfd->direction = read_direction;
|
|
|
|
|
|
|
|
|
|
stream = open (nbfd, open_closure);
|
|
|
|
|
if (stream == NULL)
|
|
|
|
|
{
|
|
|
|
|
_bfd_delete_bfd (nbfd);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec = bfd_zalloc (nbfd, sizeof (struct opncls));
|
|
|
|
|
vec->stream = stream;
|
|
|
|
|
vec->pread = pread;
|
|
|
|
|
vec->close = close;
|
|
|
|
|
|
|
|
|
|
nbfd->iovec = &opncls_iovec;
|
|
|
|
|
nbfd->iostream = vec;
|
|
|
|
|
|
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-04-15 16:32:28 +02:00
|
|
|
|
/* bfd_openw -- open for writing.
|
|
|
|
|
Returns a pointer to a freshly-allocated BFD on success, or NULL.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-04-15 16:32:28 +02:00
|
|
|
|
See comment by bfd_fdopenr before you try to modify this function. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_openw
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd *bfd_openw (const char *filename, const char *target);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Create a BFD, associated with file @var{filename}, using the
|
|
|
|
|
file format @var{target}, and return a pointer to it.
|
|
|
|
|
|
|
|
|
|
Possible errors are <<bfd_error_system_call>>, <<bfd_error_no_memory>>,
|
|
|
|
|
<<bfd_error_invalid_target>>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_openw (const char *filename, const char *target)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
bfd *nbfd;
|
|
|
|
|
const bfd_target *target_vec;
|
|
|
|
|
|
|
|
|
|
/* nbfd has to point to head of malloc'ed block so that bfd_close may
|
2002-04-15 16:32:28 +02:00
|
|
|
|
reclaim it correctly. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
nbfd = _bfd_new_bfd ();
|
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
target_vec = bfd_find_target (target, nbfd);
|
|
|
|
|
if (target_vec == NULL)
|
|
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nbfd->filename = filename;
|
|
|
|
|
nbfd->direction = write_direction;
|
|
|
|
|
|
|
|
|
|
if (bfd_open_file (nbfd) == NULL)
|
|
|
|
|
{
|
2002-04-15 16:32:28 +02:00
|
|
|
|
/* File not writeable, etc. */
|
|
|
|
|
bfd_set_error (bfd_error_system_call);
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (nbfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_close
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean bfd_close (bfd *abfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
2002-10-06 11:03:06 +02:00
|
|
|
|
Close a BFD. If the BFD was open for writing, then pending
|
|
|
|
|
operations are completed and the file written out and closed.
|
|
|
|
|
If the created file is executable, then <<chmod>> is called
|
|
|
|
|
to mark it as such.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
All memory attached to the BFD is released.
|
|
|
|
|
|
|
|
|
|
The file descriptor associated with the BFD is closed (even
|
|
|
|
|
if it was passed in to BFD by <<bfd_fdopenr>>).
|
|
|
|
|
|
|
|
|
|
RETURNS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
<<TRUE>> is returned if all is ok, otherwise <<FALSE>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_close (bfd *abfd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean ret;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-04-15 16:32:28 +02:00
|
|
|
|
if (bfd_write_p (abfd))
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
|
2002-11-30 09:39:46 +01:00
|
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
|
2002-11-30 09:39:46 +01:00
|
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* opncls.c (_bfd_new_bfd_contained_in): Copy "iovec".
(struct opncls, opncls_btell, opncls_bseek, opncls_bread)
(opncls_bwrite, opncls_bclose, opncls_bflush)
(opncls_bstat, opncls_iovec, bfd_openr_iovec): Implement a
bfd iovec that uses function callbacks.
(bfd_close): Use the iovec's bclose.
* cache.c (cache_btell, cache_bseek, cache_bread, cache_bwrite)
(cache_bclose, cache_bflush, cache_bstat)
(cache_iovec): New functions and global variable, implement a
cache "iovec", where applicable set bfd_error.
(bfd_cache_init, bfd_cache_close): Set/test the bfd's iovec.
* bfdio.c (struct bfd_iovec): Define.
(real_read): Delete function.
(bfd_bread, bfd_bread, bfd_bwrite, bfd_tell, bfd_flush, bfd_stat)
(bfd_seek, bfd_get_mtime, bfd_get_size): Use the bfd's "iovec",
assume that bread and bwrite set bfd_error.
* bfd.c (struct bfd): Add "iovec", update comments.
* bfd-in2.h, libbfd.h: Re-generate.
2004-04-21 19:05:12 +02:00
|
|
|
|
/* FIXME: cagney/2004-02-15: Need to implement a BFD_IN_MEMORY io
|
|
|
|
|
vector. */
|
|
|
|
|
if (!(abfd->flags & BFD_IN_MEMORY))
|
|
|
|
|
ret = abfd->iovec->bclose (abfd);
|
|
|
|
|
else
|
2004-10-24 20:45:38 +02:00
|
|
|
|
ret = TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
/* If the file was open for writing and is now executable,
|
2002-04-15 16:32:28 +02:00
|
|
|
|
make it so. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
if (ret
|
|
|
|
|
&& abfd->direction == write_direction
|
|
|
|
|
&& abfd->flags & EXEC_P)
|
|
|
|
|
{
|
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
|
|
if (stat (abfd->filename, &buf) == 0)
|
|
|
|
|
{
|
2002-10-06 11:03:06 +02:00
|
|
|
|
unsigned int mask = umask (0);
|
2002-04-15 16:32:28 +02:00
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
umask (mask);
|
|
|
|
|
chmod (abfd->filename,
|
|
|
|
|
(0777
|
|
|
|
|
& (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (abfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_close_all_done
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean bfd_close_all_done (bfd *);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
2002-10-06 11:03:06 +02:00
|
|
|
|
Close a BFD. Differs from <<bfd_close>> since it does not
|
|
|
|
|
complete any pending operations. This routine would be used
|
|
|
|
|
if the application had just used BFD for swapping and didn't
|
|
|
|
|
want to use any of the writing code.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
If the created file is executable, then <<chmod>> is called
|
|
|
|
|
to mark it as such.
|
|
|
|
|
|
|
|
|
|
All memory attached to the BFD is released.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
<<TRUE>> is returned if all is ok, otherwise <<FALSE>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_close_all_done (bfd *abfd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean ret;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
ret = bfd_cache_close (abfd);
|
|
|
|
|
|
|
|
|
|
/* If the file was open for writing and is now executable,
|
2002-04-15 16:32:28 +02:00
|
|
|
|
make it so. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
if (ret
|
|
|
|
|
&& abfd->direction == write_direction
|
|
|
|
|
&& abfd->flags & EXEC_P)
|
|
|
|
|
{
|
|
|
|
|
struct stat buf;
|
|
|
|
|
|
|
|
|
|
if (stat (abfd->filename, &buf) == 0)
|
|
|
|
|
{
|
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
|
|
|
|
unsigned int mask = umask (0);
|
2002-04-15 16:32:28 +02:00
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
umask (mask);
|
|
|
|
|
chmod (abfd->filename,
|
2000-05-26 09:32:26 +02:00
|
|
|
|
(0777
|
1999-05-03 09:29:11 +02:00
|
|
|
|
& (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
|
_bfd_delete_bfd (abfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_create
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd *bfd_create (const char *filename, bfd *templ);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
2002-10-06 11:03:06 +02:00
|
|
|
|
Create a new BFD in the manner of <<bfd_openw>>, but without
|
|
|
|
|
opening a file. The new BFD takes the target from the target
|
|
|
|
|
used by @var{template}. The format is always set to <<bfd_object>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_create (const char *filename, bfd *templ)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
bfd *nbfd;
|
|
|
|
|
|
|
|
|
|
nbfd = _bfd_new_bfd ();
|
|
|
|
|
if (nbfd == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
nbfd->filename = filename;
|
|
|
|
|
if (templ)
|
|
|
|
|
nbfd->xvec = templ->xvec;
|
|
|
|
|
nbfd->direction = no_direction;
|
|
|
|
|
bfd_set_format (nbfd, bfd_object);
|
2002-04-15 16:32:28 +02:00
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return nbfd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_make_writable
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean bfd_make_writable (bfd *abfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Takes a BFD as created by <<bfd_create>> and converts it
|
|
|
|
|
into one like as returned by <<bfd_openw>>. It does this
|
|
|
|
|
by converting the BFD to BFD_IN_MEMORY. It's assumed that
|
|
|
|
|
you will call <<bfd_make_readable>> on this bfd later.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
<<TRUE>> is returned if all is ok, otherwise <<FALSE>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_make_writable (bfd *abfd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
struct bfd_in_memory *bim;
|
|
|
|
|
|
|
|
|
|
if (abfd->direction != no_direction)
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bim = bfd_malloc (sizeof (struct bfd_in_memory));
|
|
|
|
|
abfd->iostream = bim;
|
2002-04-15 16:32:28 +02:00
|
|
|
|
/* bfd_bwrite will grow these as needed. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
bim->size = 0;
|
|
|
|
|
bim->buffer = 0;
|
|
|
|
|
|
|
|
|
|
abfd->flags |= BFD_IN_MEMORY;
|
|
|
|
|
abfd->direction = write_direction;
|
|
|
|
|
abfd->where = 0;
|
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_make_readable
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean bfd_make_readable (bfd *abfd);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Takes a BFD as created by <<bfd_create>> and
|
|
|
|
|
<<bfd_make_writable>> and converts it into one like as
|
|
|
|
|
returned by <<bfd_openr>>. It does this by writing the
|
|
|
|
|
contents out to the memory buffer, then reversing the
|
|
|
|
|
direction.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
2002-11-30 09:39:46 +01:00
|
|
|
|
<<TRUE>> is returned if all is ok, otherwise <<FALSE>>. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
bfd_boolean
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_make_readable (bfd *abfd)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
if (abfd->direction != write_direction || !(abfd->flags & BFD_IN_MEMORY))
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)))
|
2002-11-30 09:39:46 +01:00
|
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
|
2002-11-30 09:39:46 +01:00
|
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abfd->arch_info = &bfd_default_arch_struct;
|
|
|
|
|
|
|
|
|
|
abfd->where = 0;
|
|
|
|
|
abfd->format = bfd_unknown;
|
2003-06-29 12:06:40 +02:00
|
|
|
|
abfd->my_archive = NULL;
|
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
|
|
|
|
abfd->origin = 0;
|
2002-11-30 09:39:46 +01:00
|
|
|
|
abfd->opened_once = FALSE;
|
|
|
|
|
abfd->output_has_begun = FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
abfd->section_count = 0;
|
2003-06-29 12:06:40 +02:00
|
|
|
|
abfd->usrdata = NULL;
|
2002-11-30 09:39:46 +01:00
|
|
|
|
abfd->cacheable = FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
abfd->flags = BFD_IN_MEMORY;
|
2002-11-30 09:39:46 +01:00
|
|
|
|
abfd->mtime_set = FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
|
abfd->target_defaulted = TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
abfd->direction = read_direction;
|
|
|
|
|
abfd->sections = 0;
|
|
|
|
|
abfd->symcount = 0;
|
|
|
|
|
abfd->outsymbols = 0;
|
|
|
|
|
abfd->tdata.any = 0;
|
|
|
|
|
|
2002-04-26 15:43:10 +02:00
|
|
|
|
bfd_section_list_clear (abfd);
|
|
|
|
|
bfd_check_format (abfd, bfd_object);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
INTERNAL_FUNCTION
|
|
|
|
|
bfd_alloc
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2004-04-23 02:22:57 +02:00
|
|
|
|
void *bfd_alloc (bfd *abfd, bfd_size_type wanted);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Allocate a block of @var{wanted} bytes of memory attached to
|
|
|
|
|
<<abfd>> and return a pointer to it.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
void *
|
|
|
|
|
bfd_alloc (bfd *abfd, bfd_size_type size)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2003-06-29 12:06:40 +02:00
|
|
|
|
void *ret;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
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 (size != (unsigned long) size)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_no_memory);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
|
ret = objalloc_alloc (abfd->memory, (unsigned long) size);
|
|
|
|
|
if (ret == NULL)
|
|
|
|
|
bfd_set_error (bfd_error_no_memory);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2005-02-23 04:49:41 +01:00
|
|
|
|
/*
|
|
|
|
|
INTERNAL_FUNCTION
|
|
|
|
|
bfd_zalloc
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
|
void *bfd_zalloc (bfd *abfd, bfd_size_type wanted);
|
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Allocate a block of @var{wanted} bytes of zeroed memory
|
|
|
|
|
attached to <<abfd>> and return a pointer to it.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
void *
|
|
|
|
|
bfd_zalloc (bfd *abfd, bfd_size_type size)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
2003-06-29 12:06:40 +02:00
|
|
|
|
void *res;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
res = bfd_alloc (abfd, size);
|
|
|
|
|
if (res)
|
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
|
|
|
|
memset (res, 0, (size_t) size);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
|
/* Free a block allocated for a BFD.
|
|
|
|
|
Note: Also frees all more recently allocated blocks! */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
|
|
void
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_release (bfd *abfd, void *block)
|
1999-05-03 09:29:11 +02:00
|
|
|
|
{
|
|
|
|
|
objalloc_free_block ((struct objalloc *) abfd->memory, block);
|
|
|
|
|
}
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
|
2004-10-10 15:58:05 +02:00
|
|
|
|
/*
|
|
|
|
|
GNU Extension: separate debug-info files
|
|
|
|
|
|
2003-01-31 11:04:16 +01:00
|
|
|
|
The idea here is that a special section called .gnu_debuglink might be
|
|
|
|
|
embedded in a binary file, which indicates that some *other* file
|
|
|
|
|
contains the real debugging information. This special section contains a
|
|
|
|
|
filename and CRC32 checksum, which we read and resolve to another file,
|
|
|
|
|
if it exists.
|
|
|
|
|
|
|
|
|
|
This facilitates "optional" provision of debugging information, without
|
|
|
|
|
having to provide two complete copies of every binary object (with and
|
|
|
|
|
without debug symbols).
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-12 09:23:31 +02:00
|
|
|
|
#define GNU_DEBUGLINK ".gnu_debuglink"
|
2003-01-31 11:04:16 +01:00
|
|
|
|
/*
|
2003-06-12 09:23:31 +02:00
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_calc_gnu_debuglink_crc32
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
unsigned long bfd_calc_gnu_debuglink_crc32
|
|
|
|
|
(unsigned long crc, const unsigned char *buf, bfd_size_type len);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
2003-06-12 09:23:31 +02:00
|
|
|
|
Computes a CRC value as used in the .gnu_debuglink section.
|
|
|
|
|
Advances the previously computed @var{crc} value by computing
|
|
|
|
|
and adding in the crc32 for @var{len} bytes of @var{buf}.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
Return the updated CRC32 value.
|
2004-10-10 15:58:05 +02:00
|
|
|
|
*/
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
2003-06-12 09:23:31 +02:00
|
|
|
|
unsigned long
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_calc_gnu_debuglink_crc32 (unsigned long crc,
|
|
|
|
|
const unsigned char *buf,
|
|
|
|
|
bfd_size_type len)
|
2003-01-31 11:04:16 +01:00
|
|
|
|
{
|
|
|
|
|
static const unsigned long crc32_table[256] =
|
|
|
|
|
{
|
|
|
|
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
|
|
|
|
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
|
|
|
|
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
|
|
|
|
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
|
|
|
|
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
|
|
|
|
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
|
|
|
|
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
|
|
|
|
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
|
|
|
|
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
|
|
|
|
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
|
|
|
|
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
|
|
|
|
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
|
|
|
|
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
|
|
|
|
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
|
|
|
|
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
|
|
|
|
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
|
|
|
|
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
|
|
|
|
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
|
|
|
|
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
|
|
|
|
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
|
|
|
|
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
|
|
|
|
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
|
|
|
|
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
|
|
|
|
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
|
|
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
|
|
|
|
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
|
|
|
|
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
|
|
|
|
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
|
|
|
|
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
|
|
|
|
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
|
|
|
|
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
|
|
|
|
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
|
|
|
|
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
|
|
|
|
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
|
|
|
|
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
|
|
|
|
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
|
|
|
|
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
|
|
|
|
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
|
|
|
|
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
|
|
|
|
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
|
|
|
|
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
|
|
|
|
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
|
|
|
|
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
|
|
|
|
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
|
|
|
|
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
|
|
|
|
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
|
|
|
|
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
|
|
|
|
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
|
|
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
|
|
|
|
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
|
|
|
|
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
|
|
|
|
0x2d02ef8d
|
|
|
|
|
};
|
|
|
|
|
const unsigned char *end;
|
|
|
|
|
|
|
|
|
|
crc = ~crc & 0xffffffff;
|
|
|
|
|
for (end = buf + len; buf < end; ++ buf)
|
|
|
|
|
crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
|
|
|
|
|
return ~crc & 0xffffffff;;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
INTERNAL_FUNCTION
|
|
|
|
|
get_debug_link_info
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
char *get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
fetch the filename and CRC32 value for any separate debuginfo
|
|
|
|
|
associated with @var{abfd}. Return NULL if no such info found,
|
|
|
|
|
otherwise return filename and update @var{crc32_out}.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static char *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
get_debug_link_info (bfd *abfd, unsigned long *crc32_out)
|
2003-01-31 11:04:16 +01:00
|
|
|
|
{
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
|
|
|
|
asection *sect;
|
2003-01-31 11:04:16 +01:00
|
|
|
|
unsigned long crc32;
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
|
|
|
|
bfd_byte *contents;
|
2003-01-31 11:04:16 +01:00
|
|
|
|
int crc_offset;
|
2005-02-20 15:59:07 +01:00
|
|
|
|
char *name;
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (abfd);
|
|
|
|
|
BFD_ASSERT (crc32_out);
|
|
|
|
|
|
2003-06-12 09:23:31 +02:00
|
|
|
|
sect = bfd_get_section_by_name (abfd, GNU_DEBUGLINK);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
if (sect == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
|
|
|
|
if (!bfd_malloc_and_get_section (abfd, sect, &contents))
|
2003-01-31 11:04:16 +01:00
|
|
|
|
{
|
bfd/
* section.c (struct sec): Rename "_cooked_size" to "size".
Rename "_raw_size" to "rawsize".
(STD_SECTION): Adjust comments.
(bfd_set_section_size, bfd_get_section_contents): Use size.
(bfd_malloc_and_get_section): New function.
* bfd-in.h (bfd_section_size, bfd_get_section_size): Use size.
* coff-sh.c (sh_relax_section): Alloc coff_section_data struct early.
Correctly free reloc and contents memory.
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame): Delete FIXME
and fake CIE now that we can shink section size to zero.
(_bfd_elf_write_section_eh_frame): Likewise..
* elf32-ppc.c (ppc_elf_relax_section): Delay reading section contents.
* elf-m10300.c (mn10300_elf_final_link_relocate): Don't use
_bfd_stab_section_offset. Use _bfd_elf_section_offset.
* stabs.c (_bfd_stab_section_offset_): Remove unused args and
unneeded indirection.
* elf.c (_bfd_elf_section_offset): .. and update call.
* libbfd-in.h (_bfd_stab_section_offset): Update prototype.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
Replace occurrences of "_raw_size" and "_cooked_size" in most places
with "size". Set new "rawsize" for stabs, eh_frame, and SEC_MERGE
sections. Use "rawsize", if non-zero, for bfd_get_section_contents
calls if the section might be a stabs, eh_frame, or SEC_MERGE section.
Similarly use "rawsize", if non-zero, in reloc functions to validate
reloc addresses. Use new bfd_malloc_and_get_section in most places
where bfd_get_section_contents was called. Expand all occurrences of
bfd_section_size and bfd_get_section_size. Rename "raw_size" var in
grok_prstatus and similar functions to "size".
* aix386-core.c (aix386_core_file_p): ..
* aix5ppc-core.c (xcoff64_core_p): ..
* aout-adobe.c (aout_adobe_callback, aout_adobe_write_object_contents,
aout_adobe_set_section_contents): ..
* aout-target.h (callback): ..
* aout-tic30.c (tic30_aout_callback, tic30_aout_final_link_relocate,
MY_bfd_final_link): ..
* aoutf1.h (sunos4_core_file_p): ..
* aoutx.h (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, translate_from_native_sym_flags,
final_link, aout_link_input_section): ..
* binary.c (binary_object_p, binary_canonicalize_symtab,
binary_set_section_contents): ..
* bout.c (b_out_callback, b_out_write_object_contents,
b_out_set_section_contents, b_out_bfd_relax_section,
b_out_bfd_get_relocated_section_contents): ..
* cisco-core.c (cisco_core_file_validate): ..
* coff-alpha.c (alpha_ecoff_object_p,
alpha_ecoff_get_relocated_section_conten, alpha_relocate_section): ..
* coff-arm.c (coff_arm_relocate_section,
bfd_arm_allocate_interworking_sections): ..
* coff-h8300.c (h8300_reloc16_extra_cases,
h8300_bfd_link_add_symbols): ..
* coff-mips.c (mips_refhi_reloc, mips_gprel_reloc): ..
* coff-ppc.c (coff_ppc_relocate_section, ppc_allocate_toc_section,
ppc_bfd_coff_final_link): ..
* coff-rs6000.c (xcoff_reloc_type_br, xcoff_ppc_relocate_section): ..
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_align_loads, sh_coff_get_relocated_section_contents): ..
* coff64-rs6000.c (xcoff64_write_object_contents,
xcoff64_reloc_type_br, xcoff64_ppc_relocate_section): ..
* coffcode.h (coff_compute_section_file_positions,
coff_write_object_contents): ..
* coffgen.c (make_a_section_from_file, coff_write_symbols,
coff_section_symbol, build_debug_section): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_final_link,
process_embedded_commands, _bfd_coff_link_input_bfd,
_bfd_coff_write_global_sym): ..
* cpu-arm.c (bfd_arm_update_notes, bfd_arm_get_mach_from_notes): ..
* cpu-ns32k.c (do_ns32k_reloc, _bfd_ns32k_final_link_relocate): ..
* dwarf1.c (parse_line_table, _bfd_dwarf1_find_nearest_line): ..
* dwarf2.c (read_indirect_string, read_abbrevs, decode_line_info,
_bfd_dwarf2_find_nearest_line): ..
* ecoff.c (bfd_debug_section, ecoff_set_symbol_info,
ecoff_compute_section_file_positions,
_bfd_ecoff_write_object_contents, ecoff_indirect_link_order): ..
* elf-eh-frame.c (_bfd_elf_discard_section_eh_frame,
_bfd_elf_discard_section_eh_frame_hdr,
_bfd_elf_maybe_strip_eh_frame_hdr, _bfd_elf_eh_frame_section_offset,
_bfd_elf_write_section_eh_frame,
_bfd_elf_write_section_eh_frame_hdr): ..
* elf-hppa.h (elf_hppa_sort_unwind): ..
* elf-m10200.c (mn10200_elf_relax_section,
mn10200_elf_relax_delete_bytes,
mn10200_elf_get_relocated_section_contents): ..
* elf-m10300.c (_bfd_mn10300_elf_create_got_section,
mn10300_elf_check_relocs, mn10300_elf_relax_section,
mn10300_elf_relax_delete_bytes,
mn10300_elf_get_relocated_section_contents,
_bfd_mn10300_elf_adjust_dynamic_symbol,
_bfd_mn10300_elf_discard_copies,
_bfd_mn10300_elf_size_dynamic_sections,
_bfd_mn10300_elf_finish_dynamic_sections): ..
* elf.c (_bfd_elf_print_private_bfd_data, bfd_elf_get_bfd_needed_list,
_bfd_elf_make_section_from_phdr, elf_fake_sections,
bfd_elf_set_group_contents, map_sections_to_segments,
elf_sort_sections, assign_file_positions_for_segments,
SECTION_SIZE, copy_private_bfd_data,
_bfd_elf_get_dynamic_reloc_upper_bound,
_bfd_elf_canonicalize_dynamic_reloc, elfcore_maybe_make_sect,
_bfd_elfcore_make_pseudosection, elfcore_grok_prstatus,
elfcore_grok_lwpstatus, elfcore_grok_win32pstatus,
elfcore_grok_note, elfcore_grok_nto_status, elfcore_grok_nto_gregs,
_bfd_elf_rel_local_sym, _bfd_elf_get_synthetic_symtab): ..
* elf32-arm.h (bfd_elf32_arm_allocate_interworking_sect,
bfd_elf32_arm_process_before_allocation,
elf32_arm_adjust_dynamic_symbol, allocate_dynrelocs,
elf32_arm_size_dynamic_sections, elf32_arm_finish_dynamic_sections,
elf32_arm_write_section): ..
* elf32-cris.c (cris_elf_grok_prstatus,
elf_cris_finish_dynamic_sections, cris_elf_gc_sweep_hook,
elf_cris_adjust_gotplt_to_got, elf_cris_adjust_dynamic_symbol,
cris_elf_check_relocs, elf_cris_size_dynamic_sections,
elf_cris_discard_excess_dso_dynamics,
elf_cris_discard_excess_program_dynamics): ..
* elf32-d30v.c (bfd_elf_d30v_reloc, bfd_elf_d30v_reloc_21): ..
* elf32-dlx.c (_bfd_dlx_elf_hi16_reloc): ..
* elf32-frv.c (_frvfdpic_add_dyn_reloc, _frvfdpic_add_rofixup,
_frv_create_got_section, _frvfdpic_assign_plt_entries,
elf32_frvfdpic_size_dynamic_sections,
elf32_frvfdpic_modify_segment_map,
elf32_frvfdpic_finish_dynamic_sections): ..
* elf32-h8300.c (elf32_h8_relax_section, elf32_h8_relax_delete_bytes,
elf32_h8_get_relocated_section_contents): ..
* elf32-hppa.c (hppa_build_one_stub, hppa_size_one_stub,
elf32_hppa_adjust_dynamic_symbol, allocate_plt_static,
allocate_dynrelocs, elf32_hppa_size_dynamic_sections, group_sections,
elf32_hppa_size_stubs, elf32_hppa_set_gp, elf32_hppa_build_stubs,
elf32_hppa_finish_dynamic_sections): ..
* elf32-i370.c (i370_elf_adjust_dynamic_symbol,
i370_elf_size_dynamic_sections, i370_elf_check_relocs,
i370_elf_finish_dynamic_sections): ..
* elf32-i386.c (elf_i386_grok_prstatus, elf_i386_adjust_dynamic_symbol,
allocate_dynrelocs, elf_i386_size_dynamic_sections,
elf_i386_relocate_section, elf_i386_finish_dynamic_sections): ..
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_highadj_reloc, i860_howto_splitn_reloc): ..
* elf32-ip2k.c (ip2k_is_switch_table_128,
ip2k_relax_switch_table_128, ip2k_is_switch_table_256,
ip2k_relax_switch_table_256, ip2k_elf_relax_section,
adjust_all_relocations, ip2k_elf_relax_delete_bytes): ..
* elf32-m32r.c (m32r_elf_do_10_pcrel_reloc, m32r_elf_hi16_reloc,
m32r_elf_generic_reloc, m32r_elf_adjust_dynamic_symbol,
allocate_dynrelocs, m32r_elf_size_dynamic_sections,
m32r_elf_relocate_section, m32r_elf_finish_dynamic_sections,
m32r_elf_relax_section, m32r_elf_relax_delete_bytes,
m32r_elf_get_relocated_section_contents): ..
* elf32-m68hc11.c (m68hc11_elf_build_one_stub,
m68hc11_elf_size_one_stub, m68hc11_elf_relax_section,
m68hc11_elf_relax_delete_bytes): ..
* elf32-m68hc12.c (m68hc12_elf_build_one_stub,
m68hc12_elf_size_one_stub): ..
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs,
elf32_m68hc11_build_stubs, m68hc11_elf_special_reloc): ..
* elf32-m68k.c (elf_m68k_check_relocs, elf_m68k_gc_sweep_hook,
elf_m68k_adjust_dynamic_symbol, elf_m68k_size_dynamic_sections,
elf_m68k_discard_copies, elf_m68k_finish_dynamic_sections): ..
* elf32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elf32-or32.c (or32_elf_consth_reloc): ..
* elf32-ppc.c (ppc_elf_relax_section, ppc_elf_addr16_ha_reloc,
elf_create_pointer_linker_section, ppc_elf_create_linker_section,
ppc_elf_additional_program_headers, ppc_elf_adjust_dynamic_symbol,
allocate_dynrelocs, ppc_elf_size_dynamic_sections,
ppc_elf_finish_dynamic_sections, ppc_elf_grok_prstatus,
ppc_elf_final_write_processing): ..
* elf32-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections, elf_s390_grok_prstatus): ..
* elf32-sh.c (sh_elf_reloc_loop, sh_elf_relax_section,
sh_elf_relax_delete_bytes, sh_elf_align_loads,
sh_elf_adjust_dynamic_symbol, allocate_dynrelocs,
sh_elf_size_dynamic_sections, sh_elf_get_relocated_section_contents,
sh_elf_finish_dynamic_sections, elf32_shlin_grok_prstatus): ..
* elf32-sh64-com.c (sh64_address_in_cranges,
sh64_get_contents_type): ..
* elf32-sh64.c (sh64_find_section_for_address,
sh64_elf_final_write_processing): ..
* elf32-sparc.c (sparc_elf_wdisp16_reloc, sparc_elf_hix22_reloc,
sparc_elf_lox10_reloc, elf32_sparc_adjust_dynamic_symbol,
allocate_dynrelocs, elf32_sparc_size_dynamic_sections,
elf32_sparc_relocate_section, elf32_sparc_finish_dynamic_sections): ..
* elf32-v850.c (v850_elf_reloc, v850_elf_relax_section): ..
* elf32-vax.c (elf_vax_check_relocs, elf_vax_adjust_dynamic_symbol,
elf_vax_size_dynamic_sections, elf_vax_discard_copies,
elf_vax_instantiate_got_entries, elf_vax_relocate_section,
elf_vax_finish_dynamic_sections): ..
* elf32-xstormy16.c (xstormy16_elf_24_reloc,
xstormy16_elf_check_relocs, xstormy16_relax_plt_check,
xstormy16_elf_relax_section, xstormy16_elf_always_size_sections,
xstormy16_elf_finish_dynamic_sections): ..
* elf32-xtensa.c (xtensa_read_table_entries,
elf_xtensa_allocate_got_size, elf_xtensa_allocate_local_got_size,
elf_xtensa_size_dynamic_sections, elf_xtensa_do_reloc,
bfd_elf_xtensa_reloc, elf_xtensa_relocate_section,
elf_xtensa_combine_prop_entries, elf_xtensa_finish_dynamic_sections,
elf_xtensa_discard_info_for_section, elf_xtensa_grok_prstatus,
get_relocation_opcode, retrieve_contents, find_relaxable_sections,
collect_source_relocs, is_resolvable_asm_expansion, remove_literals,
relax_section, shrink_dynamic_reloc_sections, relax_property_section,
xtensa_callback_required_dependence): ..
* elf64-alpha.c (elf64_alpha_reloc_gpdisp, elf64_alpha_relax_section,
elf64_alpha_check_relocs, elf64_alpha_adjust_dynamic_symbol,
elf64_alpha_calc_got_offsets_for_symbol, elf64_alpha_calc_got_offsets,
elf64_alpha_size_plt_section, elf64_alpha_size_plt_section_1,
elf64_alpha_always_size_sections, elf64_alpha_calc_dynrel_sizes,
elf64_alpha_size_rela_got_section, elf64_alpha_size_rela_got_1,
elf64_alpha_size_dynamic_sections, elf64_alpha_emit_dynrel,
elf64_alpha_finish_dynamic_sections, elf64_alpha_final_link): ..
* elf64-hppa.c (allocate_dynrel_entries,
elf64_hppa_size_dynamic_sections,
elf64_hppa_finish_dynamic_sections): ..
* elf64-mips.c (mips_elf64_gprel32_reloc, mips16_gprel_reloc,
mips_elf64_canonicalize_dynamic_reloc, mips_elf64_slurp_reloc_table,
elf64_mips_grok_prstatus): ..
* elf64-mmix.c (mmix_elf_perform_relocation, mmix_elf_reloc,
mmix_elf_relocate_section, mmix_elf_final_link,
mmix_set_relaxable_size, _bfd_mmix_after_linker_allocation,
mmix_elf_relax_section, mmix_elf_get_section_contents): ..
* elf64-ppc.c (ppc64_elf_object_p, ppc64_elf_grok_prstatus,
ppc64_elf_check_relocs, ppc64_elf_func_desc_adjust,
ppc64_elf_adjust_dynamic_symbol, ppc64_elf_edit_opd,
allocate_dynrelocs, ppc64_elf_size_dynamic_sections,
ppc_build_one_stub, ppc_size_one_stub, ppc64_elf_next_toc_section,
toc_adjusting_stub_needed, group_sections, ppc64_elf_size_stubs,
ppc64_elf_build_stubs, ppc64_elf_relocate_section,
ppc64_elf_finish_dynamic_sections): ..
* elf64-s390.c (s390_elf_ldisp_reloc, elf_s390_adjust_dynamic_symbol,
allocate_dynrelocs, elf_s390_size_dynamic_sections,
elf_s390_finish_dynamic_sections): ..
* elf64-sh64.c (sh_elf64_get_relocated_section_contents,
sh_elf64_check_relocs, sh64_elf64_adjust_dynamic_symbol,
sh64_elf64_discard_copies, sh64_elf64_size_dynamic_sections,
sh64_elf64_finish_dynamic_sections): ..
* elf64-sparc.c (sparc64_elf_slurp_reloc_table, init_insn_reloc,
sparc64_elf_check_relocs, sparc64_elf_adjust_dynamic_symbol,
sparc64_elf_size_dynamic_sections, sparc64_elf_relocate_section,
sparc64_elf_finish_dynamic_symbol,
sparc64_elf_finish_dynamic_sections): ..
* elf64-x86-64.c (elf64_x86_64_grok_prstatus,
elf64_x86_64_adjust_dynamic_symbol, allocate_dynrelocs,
elf64_x86_64_size_dynamic_sections, elf64_x86_64_relocate_section,
elf64_x86_64_finish_dynamic_sections): ..
* elfarm-nabi.c (elf32_arm_nabi_grok_prstatus): ..
* elfcode.h (elf_slurp_reloc_table): ..
* elflink.c (_bfd_elf_create_got_section, elf_add_dt_needed_tag,
elf_finalize_dynstr, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_sort_relocs,
elf_link_input_bfd, bfd_elf_final_link, bfd_elf_discard_info): ..
* elfn32-mips.c (gprel32_with_gp, mips16_gprel_reloc,
elf32_mips_grok_prstatus): ..
* elfxx-ia64.c (elfNN_ia64_relax_section, allocate_dynrel_entries,
elfNN_ia64_size_dynamic_sections, elfNN_ia64_install_dyn_reloc,
elfNN_ia64_choose_gp, elfNN_ia64_final_link,
elfNN_ia64_finish_dynamic_sections): ..
* elfxx-mips.c (mips_elf_create_procedure_table,
mips_elf_check_mips16_stubs, _bfd_mips_elf_gprel16_with_gp,
_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_generic_reloc,
mips_elf_global_got_index, mips_elf_multi_got,
mips_elf_create_compact_rel_section, mips_elf_calculate_relocation,
mips_elf_allocate_dynamic_relocations,
mips_elf_create_dynamic_relocation, _bfd_mips_elf_fake_sections,
_bfd_mips_relax_section, _bfd_mips_elf_adjust_dynamic_symbol,
_bfd_mips_elf_always_size_sections,
_bfd_mips_elf_size_dynamic_sections,
_bfd_mips_elf_finish_dynamic_symbol,
_bfd_mips_elf_finish_dynamic_sections,
_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_discard_info,
_bfd_mips_elf_write_section, _bfd_mips_elf_set_section_contents,
_bfd_elf_mips_get_relocated_section_contents,
_bfd_mips_elf_final_link, _bfd_mips_elf_merge_private_bfd_data): ..
* hp300hpux.c (callback): ..
* hppabsd-core.c (make_bfd_asection): ..
* hpux-core.c (make_bfd_asection): ..
* i386linux.c (linux_link_create_dynamic_sections,
bfd_i386linux_size_dynamic_sections, linux_finish_dynamic_link): ..
* i386msdos.c (msdos_write_object_contents): ..
* i386os9k.c (os9k_callback, os9k_write_object_contents,
os9k_set_section_contents): ..
* ieee.c (parse_expression, ieee_slurp_external_symbols,
ieee_slurp_sections, ieee_slurp_debug, ieee_slurp_section_data,
ieee_write_section_part, do_with_relocs, do_as_repeat,
do_without_relocs, ieee_write_debug_part, init_for_output,
ieee_set_section_contents): ..
* ihex.c (ihex_scan, ihex_read_section, ihex_get_section_contents): ..
* irix-core.c (do_sections, make_bfd_asection): ..
* libaout.h (aout_section_merge_with_text_p): ..
* libbfd.c (_bfd_generic_get_section_contents,
_bfd_generic_get_section_contents_in_window): ..
* linker.c (default_indirect_link_order): ..
* lynx-core.c (make_bfd_asection): ..
* m68klinux.c (linux_link_create_dynamic_sections,
bfd_m68klinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* mach-o.c (bfd_mach_o_make_bfd_section,
bfd_mach_o_scan_read_dylinker, bfd_mach_o_scan_read_dylib,
bfd_mach_o_scan_read_thread, bfd_mach_o_scan_read_symtab,
bfd_mach_o_scan_read_segment): ..
* merge.c (_bfd_add_merge_section, record_section, merge_strings,
_bfd_merge_sections): ..
* mmo.c (mmo_find_sec_w_addr, mmo_get_spec_section, mmo_get_loc,
mmo_map_set_sizes, mmo_canonicalize_symtab,
mmo_internal_write_section, mmo_write_object_contents): ..
* netbsd-core.c (netbsd_core_file_p): ..
* nlm32-alpha.c (nlm_alpha_read_reloc, nlm_alpha_write_import,
nlm_alpha_set_public_section): ..
* nlm32-ppc.c (nlm_powerpc_read_reloc, nlm_powerpc_write_reloc): ..
* nlm32-sparc.c (nlm_sparc_write_import): ..
* nlmcode.h (add_bfd_section, nlm_swap_auxiliary_headers_in,
nlm_compute_section_file_positions): ..
* oasys.c (oasys_object_p, oasys_slurp_section_data,
oasys_write_sections, oasys_write_data, oasys_set_section_contents): ..
* opncls.c (get_debug_link_info): ..
* osf-core.c (make_bfd_asection): ..
* pdp11.c (some_aout_object_p, adjust_o_magic, adjust_z_magic,
adjust_n_magic, adjust_sizes_and_vmas, squirt_out_relocs,
final_link, aout_link_input_section): ..
* peXXigen.c (_bfd_XXi_swap_sym_in, _bfd_XXi_swap_aouthdr_out,
pe_print_idata, pe_print_edata, pe_print_pdata, pe_print_reloc): ..
* pef.c (bfd_pef_make_bfd_section, bfd_pef_print_loader_section,
bfd_pef_scan_start_address, bfd_pef_parse_symbols): ..
* ppcboot.c (ppcboot_object_p, ppcboot_canonicalize_symtab): ..
* ptrace-core.c (ptrace_unix_core_file_p): ..
* reloc.c (bfd_perform_relocation, bfd_install_relocation,
_bfd_final_link_relocate, bfd_generic_relax_section,
bfd_generic_get_relocated_section_contents): ..
* reloc16.c (bfd_coff_reloc16_relax_section,
bfd_coff_reloc16_get_relocated_section_c): ..
* riscix.c (riscix_some_aout_object_p): ..
* rs6000-core.c (read_hdr, make_bfd_asection): ..
* sco5-core.c (make_bfd_asection): ..
* simple.c (bfd_simple_get_relocated_section_contents): ..
* som.c (som_object_setup, setup_sections, som_prep_headers,
som_write_fixups, som_begin_writing, bfd_section_from_som_symbol,
som_set_reloc_info, som_get_section_contents,
som_bfd_link_split_section): ..
* sparclinux.c (linux_link_create_dynamic_sections,
bfd_sparclinux_size_dynamic_sections, linux_finish_dynamic_link): ..
* srec.c (srec_scan, srec_read_section, srec_get_section_contents): ..
* stabs.c (_bfd_link_section_stabs, _bfd_discard_section_stabs,
_bfd_write_stab_strings, _bfd_stab_section_offset): ..
* sunos.c (sunos_read_dynamic_info, sunos_create_dynamic_sections,
bfd_sunos_size_dynamic_sections, sunos_scan_std_relocs,
sunos_scan_ext_relocs, sunos_scan_dynamic_symbol,
sunos_write_dynamic_symbol, sunos_check_dynamic_reloc,
sunos_finish_dynamic_link): ..
* syms.c (_bfd_stab_section_find_nearest_line): ..
* tekhex.c (first_phase, tekhex_set_section_contents,
tekhex_write_object_contents): ..
* trad-core.c (trad_unix_core_file_p): ..
* versados.c (process_esd, process_otr, process_otr): ..
* vms-gsd.c (_bfd_vms_slurp_gsd, _bfd_vms_write_gsd): ..
* vms-misc.c (add_new_contents): ..
* vms-tir.c (check_section, new_section, _bfd_vms_write_tir): ..
* vms.c (vms_set_section_contents): ..
* xcofflink.c (xcoff_get_section_contents, xcoff_link_add_symbols,
xcoff_sweep, bfd_xcoff_size_dynamic_sections, xcoff_build_ldsyms,
_bfd_xcoff_bfd_final_link, xcoff_link_input_bfd): ..
* xsym.c (bfd_sym_scan): .. See above.
binutils/
* objcopy.c (copy_section): Don't set _cooked_size.
include/
* bfdlink.h (struct bfd_link_order): Update comment.
ld/
* ldlang.c (print_output_section_statement): Don't print size before
relaxation.
(IGNORE_SECTION): Remove bfd arg. Update all callers.
* ldexp.c (fold_name): .. See below.
* ldlang.c (section_already_linked, print_output_section_statement,
print_input_section, insert_pad, size_input_section,
lang_check_section_addresses, lang_size_sections_1,
lang_size_sections, lang_do_assignments_1, lang_set_startof,
lang_one_common, lang_reset_memory_regions, lang_process,
lang_abs_symbol_at_end_of, lang_do_version_exports_section): ..
* ldwrite.c (build_link_order, clone_section, ds, split_sections): ..
* pe-dll.c (process_def_file, generate_reloc): ..
* emultempl/elf32.em (gld${EMULATION_NAME}_find_statement_assignment,
gld${EMULATION_NAME}_before_allocation): ..
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): ..
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_before_allocation,
sh64_elf_${EMULATION_NAME}_after_allocation): ..
* emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): ..
* emultempl/xtensaelf.em (ld_assign_relative_paged_dot,
ld_local_file_relocations_fit, ld_xtensa_insert_page_offsets): Use
"size" instead of "_raw_size" and "_cooked_size". Expand
bfd_section_size macro invocations.
2004-06-24 06:46:28 +02:00
|
|
|
|
if (contents != NULL)
|
|
|
|
|
free (contents);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Crc value is stored after the filename, aligned up to 4 bytes. */
|
2005-02-20 15:59:07 +01:00
|
|
|
|
name = (char *) contents;
|
|
|
|
|
crc_offset = strlen (name) + 1;
|
2003-01-31 11:04:16 +01:00
|
|
|
|
crc_offset = (crc_offset + 3) & ~3;
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
crc32 = bfd_get_32 (abfd, contents + crc_offset);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
*crc32_out = crc32;
|
2005-02-20 15:59:07 +01:00
|
|
|
|
return name;
|
2003-01-31 11:04:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
INTERNAL_FUNCTION
|
|
|
|
|
separate_debug_file_exists
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_boolean separate_debug_file_exists
|
|
|
|
|
(char *name, unsigned long crc32);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Checks to see if @var{name} is a file and if its contents
|
|
|
|
|
match @var{crc32}.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
2003-06-29 12:06:40 +02:00
|
|
|
|
separate_debug_file_exists (const char *name, const unsigned long crc)
|
2003-01-31 11:04:16 +01:00
|
|
|
|
{
|
2005-02-20 15:59:07 +01:00
|
|
|
|
static unsigned char buffer [8 * 1024];
|
2003-01-31 11:04:16 +01:00
|
|
|
|
unsigned long file_crc = 0;
|
|
|
|
|
int fd;
|
2003-06-12 09:23:31 +02:00
|
|
|
|
bfd_size_type count;
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
BFD_ASSERT (name);
|
|
|
|
|
|
|
|
|
|
fd = open (name, O_RDONLY);
|
|
|
|
|
if (fd < 0)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
while ((count = read (fd, buffer, sizeof (buffer))) > 0)
|
2003-06-12 09:23:31 +02:00
|
|
|
|
file_crc = bfd_calc_gnu_debuglink_crc32 (file_crc, buffer, count);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
|
|
|
|
|
|
return crc == file_crc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
INTERNAL_FUNCTION
|
|
|
|
|
find_separate_debug_file
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
char *find_separate_debug_file (bfd *abfd);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Searches @var{abfd} for a reference to separate debugging
|
|
|
|
|
information, scans various locations in the filesystem, including
|
|
|
|
|
the file tree rooted at @var{debug_file_directory}, and returns a
|
|
|
|
|
filename of such debugging information if the file is found and has
|
|
|
|
|
matching CRC32. Returns NULL if no reference to debugging file
|
|
|
|
|
exists, or file cannot be found.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static char *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
find_separate_debug_file (bfd *abfd, const char *debug_file_directory)
|
2003-01-31 11:04:16 +01:00
|
|
|
|
{
|
|
|
|
|
char *basename;
|
|
|
|
|
char *dir;
|
|
|
|
|
char *debugfile;
|
|
|
|
|
unsigned long crc32;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (abfd);
|
|
|
|
|
if (debug_file_directory == NULL)
|
|
|
|
|
debug_file_directory = ".";
|
|
|
|
|
|
|
|
|
|
/* BFD may have been opened from a stream. */
|
|
|
|
|
if (! abfd->filename)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
basename = get_debug_link_info (abfd, & crc32);
|
2003-03-31 20:13:25 +02:00
|
|
|
|
if (basename == NULL)
|
2003-01-31 11:04:16 +01:00
|
|
|
|
return NULL;
|
2003-06-12 09:23:31 +02:00
|
|
|
|
|
2003-03-31 20:13:25 +02:00
|
|
|
|
if (strlen (basename) < 1)
|
|
|
|
|
{
|
|
|
|
|
free (basename);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
2003-06-12 09:23:31 +02:00
|
|
|
|
dir = strdup (abfd->filename);
|
|
|
|
|
if (dir == NULL)
|
|
|
|
|
{
|
|
|
|
|
free (basename);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-01-31 11:04:16 +01:00
|
|
|
|
BFD_ASSERT (strlen (dir) != 0);
|
2004-10-10 15:58:05 +02:00
|
|
|
|
|
2003-01-31 11:04:16 +01:00
|
|
|
|
/* Strip off filename part. */
|
|
|
|
|
for (i = strlen (dir) - 1; i >= 0; i--)
|
|
|
|
|
if (IS_DIR_SEPARATOR (dir[i]))
|
|
|
|
|
break;
|
2004-01-21 12:17:53 +01:00
|
|
|
|
|
2003-01-31 11:04:16 +01:00
|
|
|
|
dir[i + 1] = '\0';
|
2004-10-10 15:58:05 +02:00
|
|
|
|
BFD_ASSERT (dir[i] == '/' || dir[0] == '\0');
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
2003-06-12 09:23:31 +02:00
|
|
|
|
debugfile = malloc (strlen (debug_file_directory) + 1
|
|
|
|
|
+ strlen (dir)
|
|
|
|
|
+ strlen (".debug/")
|
2004-10-10 15:58:05 +02:00
|
|
|
|
+ strlen (basename)
|
2003-06-12 09:23:31 +02:00
|
|
|
|
+ 1);
|
|
|
|
|
if (debugfile == NULL)
|
|
|
|
|
{
|
|
|
|
|
free (basename);
|
|
|
|
|
free (dir);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
/* First try in the same directory as the original file: */
|
|
|
|
|
strcpy (debugfile, dir);
|
|
|
|
|
strcat (debugfile, basename);
|
|
|
|
|
|
|
|
|
|
if (separate_debug_file_exists (debugfile, crc32))
|
|
|
|
|
{
|
|
|
|
|
free (basename);
|
|
|
|
|
free (dir);
|
|
|
|
|
return debugfile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Then try in a subdirectory called .debug. */
|
|
|
|
|
strcpy (debugfile, dir);
|
|
|
|
|
strcat (debugfile, ".debug/");
|
|
|
|
|
strcat (debugfile, basename);
|
|
|
|
|
|
|
|
|
|
if (separate_debug_file_exists (debugfile, crc32))
|
|
|
|
|
{
|
|
|
|
|
free (basename);
|
|
|
|
|
free (dir);
|
|
|
|
|
return debugfile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Then try in the global debugfile directory. */
|
|
|
|
|
strcpy (debugfile, debug_file_directory);
|
|
|
|
|
i = strlen (debug_file_directory) - 1;
|
|
|
|
|
if (i > 0
|
|
|
|
|
&& debug_file_directory[i] != '/'
|
|
|
|
|
&& dir[0] != '/')
|
|
|
|
|
strcat (debugfile, "/");
|
|
|
|
|
strcat (debugfile, dir);
|
|
|
|
|
strcat (debugfile, basename);
|
|
|
|
|
|
|
|
|
|
if (separate_debug_file_exists (debugfile, crc32))
|
|
|
|
|
{
|
|
|
|
|
free (basename);
|
|
|
|
|
free (dir);
|
|
|
|
|
return debugfile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free (debugfile);
|
|
|
|
|
free (basename);
|
|
|
|
|
free (dir);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_follow_gnu_debuglink
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
|
|
Takes a BFD and searches it for a .gnu_debuglink section. If this
|
2004-01-21 12:17:53 +01:00
|
|
|
|
section is found, it examines the section for the name and checksum
|
|
|
|
|
of a '.debug' file containing auxiliary debugging information. It
|
|
|
|
|
then searches the filesystem for this .debug file in some standard
|
2003-01-31 11:04:16 +01:00
|
|
|
|
locations, including the directory tree rooted at @var{dir}, and if
|
2004-01-21 12:17:53 +01:00
|
|
|
|
found returns the full filename.
|
|
|
|
|
|
|
|
|
|
If @var{dir} is NULL, it will search a default path configured into
|
|
|
|
|
libbfd at build time. [XXX this feature is not currently
|
|
|
|
|
implemented].
|
2003-01-31 11:04:16 +01:00
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
<<NULL>> on any errors or failure to locate the .debug file,
|
|
|
|
|
otherwise a pointer to a heap-allocated string containing the
|
2004-01-21 12:17:53 +01:00
|
|
|
|
filename. The caller is responsible for freeing this string.
|
2003-01-31 11:04:16 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
char *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_follow_gnu_debuglink (bfd *abfd, const char *dir)
|
2003-01-31 11:04:16 +01:00
|
|
|
|
{
|
|
|
|
|
return find_separate_debug_file (abfd, dir);
|
|
|
|
|
}
|
2003-06-12 09:23:31 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
2003-06-27 10:01:28 +02:00
|
|
|
|
bfd_create_gnu_debuglink_section
|
2003-06-12 09:23:31 +02:00
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-10-19 Andrew Cagney <cagney@redhat.com>
* targets.c: Replace "struct sec" with "struct bfd_section"
* syms.c, sparclynx.c, section.c, opncls.c: Ditto.
* libcoff-in.h, libbfd-in.h, elfxx-target.h: Ditto.
* elf.c, coffgen.c, bfd.c, bfd-in.h, aoutf1.h: Ditto.
* aout-tic30.c, aout-target.h:
* bfd-in2.h, libcoff.h, libbfd.h: Regenerate.
Index: binutils/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* coffgrok.h (coff_section): Replace 'struct sec" with "struct
bfd_section".
Index: gdb/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* symtab.c: Replace "struct sec" with "struct bfd_section".
* objfiles.c, linespec.c, blockframe.c, block.c: Ditto.
Index: ld/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* pe-dll.c: Replace "struct sec" with "struct bfd_section".
Index: sim/common/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* sim-base.h: Replace "struct sec" with "struct bfd_section".
2003-10-20 16:38:46 +02:00
|
|
|
|
struct bfd_section *bfd_create_gnu_debuglink_section
|
2003-06-29 12:06:40 +02:00
|
|
|
|
(bfd *abfd, const char *filename);
|
2003-06-12 09:23:31 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
2003-06-27 10:01:28 +02:00
|
|
|
|
Takes a @var{BFD} and adds a .gnu_debuglink section to it. The section is sized
|
|
|
|
|
to be big enough to contain a link to the specified @var{filename}.
|
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
A pointer to the new section is returned if all is ok. Otherwise <<NULL>> is
|
2004-10-10 15:58:05 +02:00
|
|
|
|
returned and bfd_error is set.
|
2003-06-27 10:01:28 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
asection *
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_create_gnu_debuglink_section (bfd *abfd, const char *filename)
|
2003-06-27 10:01:28 +02:00
|
|
|
|
{
|
2003-06-29 12:06:40 +02:00
|
|
|
|
asection *sect;
|
|
|
|
|
bfd_size_type debuglink_size;
|
2003-06-27 10:01:28 +02:00
|
|
|
|
|
|
|
|
|
if (abfd == NULL || filename == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Strip off any path components in filename. */
|
|
|
|
|
filename = lbasename (filename);
|
2004-10-10 15:58:05 +02:00
|
|
|
|
|
2003-06-27 10:01:28 +02:00
|
|
|
|
sect = bfd_get_section_by_name (abfd, GNU_DEBUGLINK);
|
|
|
|
|
if (sect)
|
|
|
|
|
{
|
|
|
|
|
/* Section already exists. */
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sect = bfd_make_section (abfd, GNU_DEBUGLINK);
|
|
|
|
|
if (sect == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (! bfd_set_section_flags (abfd, sect,
|
|
|
|
|
SEC_HAS_CONTENTS | SEC_READONLY | SEC_DEBUGGING))
|
|
|
|
|
/* XXX Should we delete the section from the bfd ? */
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2004-10-10 15:58:05 +02:00
|
|
|
|
|
2003-06-27 10:01:28 +02:00
|
|
|
|
debuglink_size = strlen (filename) + 1;
|
|
|
|
|
debuglink_size += 3;
|
|
|
|
|
debuglink_size &= ~3;
|
|
|
|
|
debuglink_size += 4;
|
|
|
|
|
|
|
|
|
|
if (! bfd_set_section_size (abfd, sect, debuglink_size))
|
|
|
|
|
/* XXX Should we delete the section from the bfd ? */
|
|
|
|
|
return NULL;
|
2004-10-10 15:58:05 +02:00
|
|
|
|
|
2003-06-27 10:01:28 +02:00
|
|
|
|
return sect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
FUNCTION
|
|
|
|
|
bfd_fill_in_gnu_debuglink_section
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_boolean bfd_fill_in_gnu_debuglink_section
|
2003-10-19 Andrew Cagney <cagney@redhat.com>
* targets.c: Replace "struct sec" with "struct bfd_section"
* syms.c, sparclynx.c, section.c, opncls.c: Ditto.
* libcoff-in.h, libbfd-in.h, elfxx-target.h: Ditto.
* elf.c, coffgen.c, bfd.c, bfd-in.h, aoutf1.h: Ditto.
* aout-tic30.c, aout-target.h:
* bfd-in2.h, libcoff.h, libbfd.h: Regenerate.
Index: binutils/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* coffgrok.h (coff_section): Replace 'struct sec" with "struct
bfd_section".
Index: gdb/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* symtab.c: Replace "struct sec" with "struct bfd_section".
* objfiles.c, linespec.c, blockframe.c, block.c: Ditto.
Index: ld/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* pe-dll.c: Replace "struct sec" with "struct bfd_section".
Index: sim/common/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* sim-base.h: Replace "struct sec" with "struct bfd_section".
2003-10-20 16:38:46 +02:00
|
|
|
|
(bfd *abfd, struct bfd_section *sect, const char *filename);
|
2003-06-27 10:01:28 +02:00
|
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
|
|
Takes a @var{BFD} and containing a .gnu_debuglink section @var{SECT}
|
|
|
|
|
and fills in the contents of the section to contain a link to the
|
|
|
|
|
specified @var{filename}. The filename should be relative to the
|
|
|
|
|
current directory.
|
2003-06-12 09:23:31 +02:00
|
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
|
<<TRUE>> is returned if all is ok. Otherwise <<FALSE>> is returned
|
2004-10-10 15:58:05 +02:00
|
|
|
|
and bfd_error is set.
|
2003-06-12 09:23:31 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bfd_boolean
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_fill_in_gnu_debuglink_section (bfd *abfd,
|
2003-10-19 Andrew Cagney <cagney@redhat.com>
* targets.c: Replace "struct sec" with "struct bfd_section"
* syms.c, sparclynx.c, section.c, opncls.c: Ditto.
* libcoff-in.h, libbfd-in.h, elfxx-target.h: Ditto.
* elf.c, coffgen.c, bfd.c, bfd-in.h, aoutf1.h: Ditto.
* aout-tic30.c, aout-target.h:
* bfd-in2.h, libcoff.h, libbfd.h: Regenerate.
Index: binutils/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* coffgrok.h (coff_section): Replace 'struct sec" with "struct
bfd_section".
Index: gdb/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* symtab.c: Replace "struct sec" with "struct bfd_section".
* objfiles.c, linespec.c, blockframe.c, block.c: Ditto.
Index: ld/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* pe-dll.c: Replace "struct sec" with "struct bfd_section".
Index: sim/common/ChangeLog
2003-10-19 Andrew Cagney <cagney@redhat.com>
* sim-base.h: Replace "struct sec" with "struct bfd_section".
2003-10-20 16:38:46 +02:00
|
|
|
|
struct bfd_section *sect,
|
2003-06-29 12:06:40 +02:00
|
|
|
|
const char *filename)
|
2003-06-12 09:23:31 +02:00
|
|
|
|
{
|
|
|
|
|
bfd_size_type debuglink_size;
|
|
|
|
|
unsigned long crc32;
|
|
|
|
|
char * contents;
|
|
|
|
|
bfd_size_type crc_offset;
|
|
|
|
|
FILE * handle;
|
2005-02-20 15:59:07 +01:00
|
|
|
|
static unsigned char buffer[8 * 1024];
|
2003-06-12 09:23:31 +02:00
|
|
|
|
size_t count;
|
|
|
|
|
|
2003-06-27 10:01:28 +02:00
|
|
|
|
if (abfd == NULL || sect == NULL || filename == NULL)
|
2003-06-12 09:23:31 +02:00
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure that we can read the file.
|
|
|
|
|
XXX - Should we attempt to locate the debug info file using the same
|
|
|
|
|
algorithm as gdb ? At the moment, since we are creating the
|
|
|
|
|
.gnu_debuglink section, we insist upon the user providing us with a
|
|
|
|
|
correct-for-section-creation-time path, but this need not conform to
|
|
|
|
|
the gdb location algorithm. */
|
|
|
|
|
handle = fopen (filename, FOPEN_RB);
|
|
|
|
|
if (handle == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_set_error (bfd_error_system_call);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
crc32 = 0;
|
|
|
|
|
while ((count = fread (buffer, 1, sizeof buffer, handle)) > 0)
|
|
|
|
|
crc32 = bfd_calc_gnu_debuglink_crc32 (crc32, buffer, count);
|
|
|
|
|
fclose (handle);
|
|
|
|
|
|
|
|
|
|
/* Strip off any path components in filename,
|
|
|
|
|
now that we no longer need them. */
|
|
|
|
|
filename = lbasename (filename);
|
2004-10-10 15:58:05 +02:00
|
|
|
|
|
2003-06-12 09:23:31 +02:00
|
|
|
|
debuglink_size = strlen (filename) + 1;
|
|
|
|
|
debuglink_size += 3;
|
|
|
|
|
debuglink_size &= ~3;
|
|
|
|
|
debuglink_size += 4;
|
|
|
|
|
|
|
|
|
|
contents = malloc (debuglink_size);
|
|
|
|
|
if (contents == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* XXX Should we delete the section from the bfd ? */
|
|
|
|
|
bfd_set_error (bfd_error_no_memory);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
strcpy (contents, filename);
|
|
|
|
|
crc_offset = debuglink_size - 4;
|
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
bfd_put_32 (abfd, crc32, contents + crc_offset);
|
2003-06-12 09:23:31 +02:00
|
|
|
|
|
2003-06-29 12:06:40 +02:00
|
|
|
|
if (! bfd_set_section_contents (abfd, sect, contents, 0, debuglink_size))
|
2003-06-12 09:23:31 +02:00
|
|
|
|
{
|
|
|
|
|
/* XXX Should we delete the section from the bfd ? */
|
|
|
|
|
free (contents);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|