include/
* bfdlink.h (struct bfd_link_info): Delete emit_note_gnu_build_id. bfd/ * configure.in: Bump version to 2.23.52. * elf-bfd.h (struct elf_build_id_info): New. (struct elf_obj_tdata): Delete after_write_object_contents, after_write_object_contents_info and build_id_size. Make build_id a pointer to struct elf_build_id_info. * elf.c (_bfd_elf_write_object_contents): Style. Update after_write_ibject_contents invocation. (elfobj_grok_gnu_build_id): Update for new build_id struct. Don't allow zero size notes. * configure: Regenerate. gdb/ * elfread.c (struct build_id): Delete. Use struct elf_build_id throughout file instead. (build_id_bfd_get): Update to use new elf_tdata build_id field. Don't xmalloc return value. (build_id_verify): Similarly. Don't xfree. (build_id_to_debug_filename): Update. (find_separate_debug_file_by_buildid): Update, don't xfree. ld/ * emultempl/elf32.em (emit_note_gnu_build_id): New static var. Replace all info->emit_note_gnu_build_id refs. (id_note_section_size): Rename from gld${EMULATION_NAME}_id_note_section_size. (struct build_id_info): Delete. (write_build_id): Rename from gld${EMULATION_NAME}_write_build_id_section. Update elf_tdata usage. Style, formatting. (setup_build_id): New function. (gld${EMULATION_NAME}_after_open): Use setup_build_id.
This commit is contained in:
parent
273e4eecfe
commit
30e8ee25e3
11 changed files with 179 additions and 139 deletions
|
@ -1,3 +1,16 @@
|
|||
2013-02-19 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* configure.in: Bump version to 2.23.52.
|
||||
* elf-bfd.h (struct elf_build_id_info): New.
|
||||
(struct elf_obj_tdata): Delete after_write_object_contents,
|
||||
after_write_object_contents_info and build_id_size. Make build_id
|
||||
a pointer to struct elf_build_id_info.
|
||||
* elf.c (_bfd_elf_write_object_contents): Style. Update
|
||||
after_write_ibject_contents invocation.
|
||||
(elfobj_grok_gnu_build_id): Update for new build_id struct. Don't
|
||||
allow zero size notes.
|
||||
* configure: Regenerate.
|
||||
|
||||
2013-02-18 Maciej W. Rozycki <macro@codesourcery.com>
|
||||
|
||||
* elf64-mips.c (micromips_elf64_howto_table_rel): Add
|
||||
|
|
20
bfd/configure
vendored
20
bfd/configure
vendored
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.64 for bfd 2.23.51.
|
||||
# Generated by GNU Autoconf 2.64 for bfd 2.23.52.
|
||||
#
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
|
||||
|
@ -556,8 +556,8 @@ MAKEFLAGS=
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='bfd'
|
||||
PACKAGE_TARNAME='bfd'
|
||||
PACKAGE_VERSION='2.23.51'
|
||||
PACKAGE_STRING='bfd 2.23.51'
|
||||
PACKAGE_VERSION='2.23.52'
|
||||
PACKAGE_STRING='bfd 2.23.52'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
|
@ -1349,7 +1349,7 @@ if test "$ac_init_help" = "long"; then
|
|||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures bfd 2.23.51 to adapt to many kinds of systems.
|
||||
\`configure' configures bfd 2.23.52 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
|
@ -1420,7 +1420,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of bfd 2.23.51:";;
|
||||
short | recursive ) echo "Configuration of bfd 2.23.52:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -1541,7 +1541,7 @@ fi
|
|||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
bfd configure 2.23.51
|
||||
bfd configure 2.23.52
|
||||
generated by GNU Autoconf 2.64
|
||||
|
||||
Copyright (C) 2009 Free Software Foundation, Inc.
|
||||
|
@ -2183,7 +2183,7 @@ cat >config.log <<_ACEOF
|
|||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by bfd $as_me 2.23.51, which was
|
||||
It was created by bfd $as_me 2.23.52, which was
|
||||
generated by GNU Autoconf 2.64. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
@ -3991,7 +3991,7 @@ fi
|
|||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='bfd'
|
||||
VERSION='2.23.51'
|
||||
VERSION='2.23.52'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
|
@ -16470,7 +16470,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
|||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by bfd $as_me 2.23.51, which was
|
||||
This file was extended by bfd $as_me 2.23.52, which was
|
||||
generated by GNU Autoconf 2.64. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -16534,7 +16534,7 @@ Report bugs to the package provider."
|
|||
_ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_version="\\
|
||||
bfd config.status 2.23.51
|
||||
bfd config.status 2.23.52
|
||||
configured by $0, generated by GNU Autoconf 2.64,
|
||||
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ dnl <http://www.gnu.org/licenses/>.
|
|||
dnl
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT([bfd], [2.23.51])
|
||||
AC_INIT([bfd], [2.23.52])
|
||||
AC_CONFIG_SRCDIR([libbfd.c])
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
|
|
|
@ -1512,6 +1512,28 @@ struct sdt_note
|
|||
bfd_byte data[1];
|
||||
};
|
||||
|
||||
/* NT_GNU_BUILD_ID note type info. */
|
||||
struct elf_build_id_info
|
||||
{
|
||||
union
|
||||
{
|
||||
/* Used on output bfd by linker. */
|
||||
struct elf_build_id_out
|
||||
{
|
||||
size_t zero; /* Always zero */
|
||||
bfd_boolean (*after_write_object_contents) (bfd *);
|
||||
const char *style;
|
||||
asection *sec;
|
||||
} o;
|
||||
/* Used for input bfd. */
|
||||
struct elf_build_id
|
||||
{
|
||||
size_t size; /* Always non-zero */
|
||||
bfd_byte data[1];
|
||||
} i;
|
||||
} u;
|
||||
};
|
||||
|
||||
/* Some private data is stashed away for future use using the tdata pointer
|
||||
in the bfd structure. */
|
||||
|
||||
|
@ -1645,13 +1667,8 @@ struct elf_obj_tdata
|
|||
obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
|
||||
obj_attribute_list *other_obj_attributes[2];
|
||||
|
||||
/* Called at the end of _bfd_elf_write_object_contents if not NULL. */
|
||||
bfd_boolean (*after_write_object_contents) (bfd *);
|
||||
void *after_write_object_contents_info;
|
||||
|
||||
/* NT_GNU_BUILD_ID note type. */
|
||||
bfd_size_type build_id_size;
|
||||
bfd_byte *build_id;
|
||||
struct elf_build_id_info *build_id;
|
||||
|
||||
/* Linked-list containing information about every Systemtap section
|
||||
found in the object file. Each section corresponds to one entry
|
||||
|
|
26
bfd/elf.c
26
bfd/elf.c
|
@ -5292,6 +5292,7 @@ _bfd_elf_write_object_contents (bfd *abfd)
|
|||
Elf_Internal_Shdr **i_shdrp;
|
||||
bfd_boolean failed;
|
||||
unsigned int count, num_sec;
|
||||
struct elf_obj_tdata *t;
|
||||
|
||||
if (! abfd->output_has_begun
|
||||
&& ! _bfd_elf_compute_section_file_positions (abfd, NULL))
|
||||
|
@ -5323,21 +5324,22 @@ _bfd_elf_write_object_contents (bfd *abfd)
|
|||
}
|
||||
|
||||
/* Write out the section header names. */
|
||||
t = elf_tdata (abfd);
|
||||
if (elf_shstrtab (abfd) != NULL
|
||||
&& (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
|
||||
&& (bfd_seek (abfd, t->shstrtab_hdr.sh_offset, SEEK_SET) != 0
|
||||
|| !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))))
|
||||
return FALSE;
|
||||
|
||||
if (bed->elf_backend_final_write_processing)
|
||||
(*bed->elf_backend_final_write_processing) (abfd,
|
||||
elf_tdata (abfd)->linker);
|
||||
(*bed->elf_backend_final_write_processing) (abfd, t->linker);
|
||||
|
||||
if (!bed->s->write_shdrs_and_ehdr (abfd))
|
||||
return FALSE;
|
||||
|
||||
/* This is last since write_shdrs_and_ehdr can touch i_shdrp[0]. */
|
||||
if (elf_tdata (abfd)->after_write_object_contents)
|
||||
return (*elf_tdata (abfd)->after_write_object_contents) (abfd);
|
||||
if (t->build_id != NULL
|
||||
&& t->build_id->u.o.zero == 0)
|
||||
return (*t->build_id->u.o.after_write_object_contents) (abfd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -8692,12 +8694,18 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
|
|||
static bfd_boolean
|
||||
elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
|
||||
{
|
||||
elf_tdata (abfd)->build_id_size = note->descsz;
|
||||
elf_tdata (abfd)->build_id = (bfd_byte *) bfd_alloc (abfd, note->descsz);
|
||||
if (elf_tdata (abfd)->build_id == NULL)
|
||||
struct elf_obj_tdata *t;
|
||||
|
||||
if (note->descsz == 0)
|
||||
return FALSE;
|
||||
|
||||
memcpy (elf_tdata (abfd)->build_id, note->descdata, note->descsz);
|
||||
t = elf_tdata (abfd);
|
||||
t->build_id = bfd_alloc (abfd, sizeof (t->build_id->u.i) - 1 + note->descsz);
|
||||
if (t->build_id == NULL)
|
||||
return FALSE;
|
||||
|
||||
t->build_id->u.i.size = note->descsz;
|
||||
memcpy (t->build_id->u.i.data, note->descdata, note->descsz);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
2013-02-19 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* elfread.c (struct build_id): Delete. Use struct elf_build_id
|
||||
throughout file instead.
|
||||
(build_id_bfd_get): Update to use new elf_tdata build_id field.
|
||||
Don't xmalloc return value.
|
||||
(build_id_verify): Similarly. Don't xfree.
|
||||
(build_id_to_debug_filename): Update.
|
||||
(find_separate_debug_file_by_buildid): Update, don't xfree.
|
||||
|
||||
2013-02-18 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
PR gdb/15102:
|
||||
|
@ -1151,7 +1161,7 @@
|
|||
|
||||
2013-01-24 Tiago Stürmer Daitx <tdaitx@linux.vnet.ibm.com>
|
||||
|
||||
* MAINTAINERS (Write After Approval): Add myself to the list.
|
||||
* MAINTAINERS (Write After Approval): Add myself to the list.
|
||||
|
||||
2013-01-24 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
|
|
|
@ -1074,38 +1074,27 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
|
|||
update_breakpoint_locations (b, sals, sals_end);
|
||||
}
|
||||
|
||||
struct build_id
|
||||
{
|
||||
size_t size;
|
||||
gdb_byte data[1];
|
||||
};
|
||||
|
||||
/* Locate NT_GNU_BUILD_ID from ABFD and return its content. */
|
||||
|
||||
static struct build_id *
|
||||
static struct elf_build_id *
|
||||
build_id_bfd_get (bfd *abfd)
|
||||
{
|
||||
struct build_id *retval;
|
||||
|
||||
if (!bfd_check_format (abfd, bfd_object)
|
||||
|| bfd_get_flavour (abfd) != bfd_target_elf_flavour
|
||||
|| elf_tdata (abfd)->build_id == NULL)
|
||||
|| elf_tdata (abfd)->build_id == NULL
|
||||
|| elf_tdata (abfd)->build_id->u.i.size == 0)
|
||||
return NULL;
|
||||
|
||||
retval = xmalloc (sizeof *retval - 1 + elf_tdata (abfd)->build_id_size);
|
||||
retval->size = elf_tdata (abfd)->build_id_size;
|
||||
memcpy (retval->data, elf_tdata (abfd)->build_id, retval->size);
|
||||
|
||||
return retval;
|
||||
return &elf_tdata (abfd)->build_id->u.i;
|
||||
}
|
||||
|
||||
/* Return if FILENAME has NT_GNU_BUILD_ID matching the CHECK value. */
|
||||
|
||||
static int
|
||||
build_id_verify (const char *filename, struct build_id *check)
|
||||
build_id_verify (const char *filename, struct elf_build_id *check)
|
||||
{
|
||||
bfd *abfd;
|
||||
struct build_id *found = NULL;
|
||||
struct elf_build_id *found;
|
||||
int retval = 0;
|
||||
|
||||
/* We expect to be silent on the non-existing files. */
|
||||
|
@ -1126,13 +1115,11 @@ build_id_verify (const char *filename, struct build_id *check)
|
|||
|
||||
gdb_bfd_unref (abfd);
|
||||
|
||||
xfree (found);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char *
|
||||
build_id_to_debug_filename (struct build_id *build_id)
|
||||
build_id_to_debug_filename (struct elf_build_id *build_id)
|
||||
{
|
||||
char *link, *debugdir, *retval = NULL;
|
||||
VEC (char_ptr) *debugdir_vec;
|
||||
|
@ -1191,7 +1178,7 @@ build_id_to_debug_filename (struct build_id *build_id)
|
|||
static char *
|
||||
find_separate_debug_file_by_buildid (struct objfile *objfile)
|
||||
{
|
||||
struct build_id *build_id;
|
||||
struct elf_build_id *build_id;
|
||||
|
||||
build_id = build_id_bfd_get (objfile->obfd);
|
||||
if (build_id != NULL)
|
||||
|
@ -1199,7 +1186,6 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
|
|||
char *build_id_name;
|
||||
|
||||
build_id_name = build_id_to_debug_filename (build_id);
|
||||
xfree (build_id);
|
||||
/* Prevent looping on a stripped .debug file. */
|
||||
if (build_id_name != NULL
|
||||
&& filename_cmp (build_id_name, objfile->name) == 0)
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
2013-02-19 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* bfdlink.h (struct bfd_link_info): Delete emit_note_gnu_build_id.
|
||||
|
||||
2013-02-11 Sriraman Tallam <tmsriram@google.com>
|
||||
|
||||
* plugin-api.h (enum ld_plugin_level): Assign integers
|
||||
explicitly for all values.
|
||||
explicitly for all values.
|
||||
|
||||
2013-02-06 Sandra Loosemore <sandra@codesourcery.com>
|
||||
Andrew Jenner <andrew@codesourcery.com>
|
||||
|
@ -153,8 +157,7 @@
|
|||
|
||||
2012-08-02 Sean Keys <skeys@ipdatasys.com>
|
||||
|
||||
* elf/m68hc11.h: #define E_M68HC11_NO_BANK_WARNING
|
||||
0x000000200
|
||||
* elf/m68hc11.h: #define E_M68HC11_NO_BANK_WARNING 0x000000200
|
||||
|
||||
2012-07-24 Stephan McCamant <smcc@cs.berkeley.edu>
|
||||
Dr David Alan Gilbert <dave@treblig.org>
|
||||
|
@ -173,8 +176,8 @@
|
|||
|
||||
2012-07-05 Sean Keys <skeys@ipdatasys.com>
|
||||
|
||||
* opcode/xgate.h: Changed the format string for mode
|
||||
XGATE_OP_DYA_MON.
|
||||
* opcode/xgate.h: Changed the format string for mode
|
||||
XGATE_OP_DYA_MON.
|
||||
|
||||
2012-06-18 Doug Evans <dje@google.com>
|
||||
|
||||
|
|
|
@ -469,9 +469,6 @@ struct bfd_link_info
|
|||
bfd *input_bfds;
|
||||
bfd **input_bfds_tail;
|
||||
|
||||
/* Non-NULL if .note.gnu.build-id section should be created. */
|
||||
char *emit_note_gnu_build_id;
|
||||
|
||||
/* If a symbol should be created for each input BFD, this is section
|
||||
where those symbols should be placed. It must be a section in
|
||||
the output BFD. It may be NULL, in which case no such symbols
|
||||
|
|
13
ld/ChangeLog
13
ld/ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2013-02-19 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* emultempl/elf32.em (emit_note_gnu_build_id): New static var.
|
||||
Replace all info->emit_note_gnu_build_id refs.
|
||||
(id_note_section_size): Rename from
|
||||
gld${EMULATION_NAME}_id_note_section_size.
|
||||
(struct build_id_info): Delete.
|
||||
(write_build_id): Rename from
|
||||
gld${EMULATION_NAME}_write_build_id_section.
|
||||
Update elf_tdata usage. Style, formatting.
|
||||
(setup_build_id): New function.
|
||||
(gld${EMULATION_NAME}_after_open): Use setup_build_id.
|
||||
|
||||
2013-02-16 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR ld/15146
|
||||
|
|
|
@ -165,6 +165,9 @@ static bfd_boolean global_vercheck_failed;
|
|||
static char *audit; /* colon (typically) separated list of libs */
|
||||
static char *depaudit; /* colon (typically) separated list of libs */
|
||||
|
||||
/* Style of .note.gnu.build-id section. */
|
||||
static const char *emit_note_gnu_build_id;
|
||||
|
||||
/* On Linux, it's possible to have different versions of the same
|
||||
shared library linked against different versions of libc. The
|
||||
dynamic linker somehow tags which libc version to use in
|
||||
|
@ -890,10 +893,9 @@ if test x"$LDEMUL_AFTER_OPEN" != xgld"$EMULATION_NAME"_after_open; then
|
|||
fragment <<EOF
|
||||
|
||||
static bfd_size_type
|
||||
gld${EMULATION_NAME}_id_note_section_size (bfd *abfd,
|
||||
struct bfd_link_info *linfo)
|
||||
id_note_section_size (bfd *abfd)
|
||||
{
|
||||
const char *style = linfo->emit_note_gnu_build_id;
|
||||
const char *style = emit_note_gnu_build_id;
|
||||
bfd_size_type size;
|
||||
|
||||
abfd = abfd;
|
||||
|
@ -944,25 +946,22 @@ read_hex (const char xdigit)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct build_id_info
|
||||
{
|
||||
const char *style;
|
||||
asection *sec;
|
||||
};
|
||||
|
||||
static bfd_boolean
|
||||
gld${EMULATION_NAME}_write_build_id_section (bfd *abfd)
|
||||
write_build_id (bfd *abfd)
|
||||
{
|
||||
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
||||
struct build_id_info *info = (struct build_id_info *)
|
||||
elf_tdata (abfd)->after_write_object_contents_info;
|
||||
struct elf_obj_tdata *t = elf_tdata (abfd);
|
||||
const char *style;
|
||||
asection *asec;
|
||||
Elf_Internal_Shdr *i_shdr;
|
||||
unsigned char *contents, *id_bits;
|
||||
bfd_size_type size;
|
||||
file_ptr position;
|
||||
Elf_External_Note *e_note;
|
||||
typedef void (*sum_fn) (const void *, size_t, void *);
|
||||
|
||||
asec = info->sec;
|
||||
style = t->build_id->u.o.style;
|
||||
asec = t->build_id->u.o.sec;
|
||||
if (bfd_is_abs_section (asec->output_section))
|
||||
{
|
||||
einfo (_("%P: warning: .note.gnu.build-id section discarded,"
|
||||
|
@ -991,31 +990,25 @@ gld${EMULATION_NAME}_write_build_id_section (bfd *abfd)
|
|||
bfd_h_put_32 (abfd, NT_GNU_BUILD_ID, &e_note->type);
|
||||
memcpy (e_note->name, "GNU", sizeof "GNU");
|
||||
|
||||
if (!strcmp (info->style, "md5"))
|
||||
if (strcmp (style, "md5") == 0)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
|
||||
md5_init_ctx (&ctx);
|
||||
if (bed->s->checksum_contents (abfd,
|
||||
(void (*) (const void *, size_t, void *))
|
||||
&md5_process_bytes,
|
||||
&ctx))
|
||||
md5_finish_ctx (&ctx, id_bits);
|
||||
else
|
||||
if (!bed->s->checksum_contents (abfd, (sum_fn) &md5_process_bytes, &ctx))
|
||||
return FALSE;
|
||||
md5_finish_ctx (&ctx, id_bits);
|
||||
}
|
||||
else if (!strcmp (info->style, "sha1"))
|
||||
else if (strcmp (style, "sha1") == 0)
|
||||
{
|
||||
struct sha1_ctx ctx;
|
||||
|
||||
sha1_init_ctx (&ctx);
|
||||
if (bed->s->checksum_contents (abfd,
|
||||
(void (*) (const void *, size_t, void *))
|
||||
&sha1_process_bytes,
|
||||
&ctx))
|
||||
sha1_finish_ctx (&ctx, id_bits);
|
||||
else
|
||||
if (!bed->s->checksum_contents (abfd, (sum_fn) &sha1_process_bytes, &ctx))
|
||||
return FALSE;
|
||||
sha1_finish_ctx (&ctx, id_bits);
|
||||
}
|
||||
else if (!strcmp (info->style, "uuid"))
|
||||
else if (strcmp (style, "uuid") == 0)
|
||||
{
|
||||
int n;
|
||||
int fd = open ("/dev/urandom", O_RDONLY);
|
||||
|
@ -1026,10 +1019,10 @@ gld${EMULATION_NAME}_write_build_id_section (bfd *abfd)
|
|||
if (n < (int) size)
|
||||
return FALSE;
|
||||
}
|
||||
else if (!strncmp (info->style, "0x", 2))
|
||||
else if (strncmp (style, "0x", 2) == 0)
|
||||
{
|
||||
/* ID is in string form (hex). Convert to bits. */
|
||||
const char *id = info->style + 2;
|
||||
const char *id = style + 2;
|
||||
size_t n = 0;
|
||||
do
|
||||
{
|
||||
|
@ -1047,12 +1040,51 @@ gld${EMULATION_NAME}_write_build_id_section (bfd *abfd)
|
|||
else
|
||||
abort (); /* Should have been validated earlier. */
|
||||
|
||||
position = i_shdr->sh_offset + asec->output_offset;
|
||||
size = asec->size;
|
||||
return (bfd_seek (abfd,
|
||||
i_shdr->sh_offset + asec->output_offset, SEEK_SET) == 0
|
||||
return (bfd_seek (abfd, position, SEEK_SET) == 0
|
||||
&& bfd_bwrite (contents, size, abfd) == size);
|
||||
}
|
||||
|
||||
/* Make .note.gnu.build-id section, and set up elf_tdata->build_id. */
|
||||
|
||||
static bfd_boolean
|
||||
setup_build_id (bfd *ibfd)
|
||||
{
|
||||
asection *s;
|
||||
bfd_size_type size;
|
||||
flagword flags;
|
||||
|
||||
size = id_note_section_size (ibfd);
|
||||
if (size == 0)
|
||||
{
|
||||
einfo ("%P: warning: unrecognized --build-id style ignored.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flags = (SEC_ALLOC | SEC_LOAD | SEC_IN_MEMORY
|
||||
| SEC_LINKER_CREATED | SEC_READONLY | SEC_DATA);
|
||||
s = bfd_make_section_with_flags (ibfd, ".note.gnu.build-id", flags);
|
||||
if (s != NULL && bfd_set_section_alignment (ibfd, s, 2))
|
||||
{
|
||||
struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
|
||||
t->build_id = bfd_alloc (link_info.output_bfd, sizeof (t->build_id->u.o));
|
||||
if (t->build_id != NULL)
|
||||
{
|
||||
t->build_id->u.o.zero = 0;
|
||||
t->build_id->u.o.after_write_object_contents = &write_build_id;
|
||||
t->build_id->u.o.style = emit_note_gnu_build_id;
|
||||
t->build_id->u.o.sec = s;
|
||||
elf_section_type (s) = SHT_NOTE;
|
||||
s->size = size;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
|
||||
" --build-id ignored.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* This is called after all the input files have been opened. */
|
||||
|
||||
|
@ -1068,11 +1100,9 @@ gld${EMULATION_NAME}_after_open (void)
|
|||
if (!is_elf_hash_table (htab))
|
||||
return;
|
||||
|
||||
if (link_info.emit_note_gnu_build_id)
|
||||
if (emit_note_gnu_build_id != NULL)
|
||||
{
|
||||
bfd *abfd;
|
||||
asection *s;
|
||||
bfd_size_type size;
|
||||
|
||||
/* Find an ELF input. */
|
||||
for (abfd = link_info.input_bfds;
|
||||
|
@ -1080,50 +1110,13 @@ gld${EMULATION_NAME}_after_open (void)
|
|||
if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
|
||||
break;
|
||||
|
||||
if (abfd == NULL)
|
||||
/* PR 10555: If there are no ELF input files do not try to
|
||||
create a .note.gnu-build-id section. */
|
||||
if (abfd == NULL
|
||||
|| !setup_build_id (abfd))
|
||||
{
|
||||
/* PR 10555: If there are no input files do not
|
||||
try to create a .note.gnu-build-id section. */
|
||||
free (link_info.emit_note_gnu_build_id);
|
||||
link_info.emit_note_gnu_build_id = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = gld${EMULATION_NAME}_id_note_section_size (abfd, &link_info);
|
||||
if (size == 0)
|
||||
{
|
||||
einfo ("%P: warning: unrecognized --build-id style ignored.\n");
|
||||
free (link_info.emit_note_gnu_build_id);
|
||||
link_info.emit_note_gnu_build_id = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = bfd_make_section_with_flags (abfd, ".note.gnu.build-id",
|
||||
SEC_ALLOC | SEC_LOAD
|
||||
| SEC_IN_MEMORY | SEC_LINKER_CREATED
|
||||
| SEC_READONLY | SEC_DATA);
|
||||
if (s != NULL && bfd_set_section_alignment (abfd, s, 2))
|
||||
{
|
||||
struct elf_obj_tdata *t = elf_tdata (link_info.output_bfd);
|
||||
struct build_id_info *b =
|
||||
(struct build_id_info *) xmalloc (sizeof *b);
|
||||
|
||||
b->style = link_info.emit_note_gnu_build_id;
|
||||
b->sec = s;
|
||||
elf_section_type (s) = SHT_NOTE;
|
||||
s->size = size;
|
||||
t->after_write_object_contents
|
||||
= &gld${EMULATION_NAME}_write_build_id_section;
|
||||
t->after_write_object_contents_info = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
einfo ("%P: warning: Cannot create .note.gnu.build-id section,"
|
||||
" --build-id ignored.\n");
|
||||
free (link_info.emit_note_gnu_build_id);
|
||||
link_info.emit_note_gnu_build_id = NULL;
|
||||
}
|
||||
}
|
||||
free ((char *) emit_note_gnu_build_id);
|
||||
emit_note_gnu_build_id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2192,15 +2185,15 @@ gld${EMULATION_NAME}_handle_option (int optc)
|
|||
return FALSE;
|
||||
|
||||
case OPTION_BUILD_ID:
|
||||
if (link_info.emit_note_gnu_build_id != NULL)
|
||||
if (emit_note_gnu_build_id != NULL)
|
||||
{
|
||||
free (link_info.emit_note_gnu_build_id);
|
||||
link_info.emit_note_gnu_build_id = NULL;
|
||||
free ((char *) emit_note_gnu_build_id);
|
||||
emit_note_gnu_build_id = NULL;
|
||||
}
|
||||
if (optarg == NULL)
|
||||
optarg = DEFAULT_BUILD_ID_STYLE;
|
||||
if (strcmp (optarg, "none"))
|
||||
link_info.emit_note_gnu_build_id = xstrdup (optarg);
|
||||
emit_note_gnu_build_id = xstrdup (optarg);
|
||||
break;
|
||||
|
||||
EOF
|
||||
|
|
Loading…
Reference in a new issue