2005-10-05 H.J. Lu <hongjiu.lu@intel.com>

PR ld/1396
	* ldcref.c (check_refs): Accept bfd_boolean.
	(check_local_sym_xref): Pass FALSE to check_refs.
	(check_nocrossref): Pass TRUE to check_refs.
	(check_refs_info): Add bfd_boolean.
	(check_refs): Add bfd_boolean to check_refs_info.
	(check_reloc_refs): Match relocations with proper symbols.

	* ldmisc.c (vfinfo): Don't add extra ":\n".
This commit is contained in:
H.J. Lu 2005-10-05 16:12:17 +00:00
parent cc96343e4c
commit f0e0fb23b5
3 changed files with 39 additions and 10 deletions

View file

@ -1,3 +1,15 @@
2005-10-05 H.J. Lu <hongjiu.lu@intel.com>
PR ld/1396
* ldcref.c (check_refs): Accept bfd_boolean.
(check_local_sym_xref): Pass FALSE to check_refs.
(check_nocrossref): Pass TRUE to check_refs.
(check_refs_info): Add bfd_boolean.
(check_refs): Add bfd_boolean to check_refs_info.
(check_reloc_refs): Match relocations with proper symbols.
* ldmisc.c (vfinfo): Don't add extra ":\n".
2005-10-05 Danny Smith <dannysmith@users.sourceforge.net> 2005-10-05 Danny Smith <dannysmith@users.sourceforge.net>
* emultempl/pe.em (gld_${EMULATION_NAME}_before_parse): Set * emultempl/pe.em (gld_${EMULATION_NAME}_before_parse): Set

View file

@ -71,7 +71,7 @@ struct cref_hash_table {
static void output_one_cref (FILE *, struct cref_hash_entry *); static void output_one_cref (FILE *, struct cref_hash_entry *);
static void check_local_sym_xref (lang_input_statement_type *); static void check_local_sym_xref (lang_input_statement_type *);
static bfd_boolean check_nocrossref (struct cref_hash_entry *, void *); static bfd_boolean check_nocrossref (struct cref_hash_entry *, void *);
static void check_refs (const char *, asection *, bfd *, static void check_refs (const char *, bfd_boolean, asection *, bfd *,
struct lang_nocrossrefs *); struct lang_nocrossrefs *);
static void check_reloc_refs (bfd *, asection *, void *); static void check_reloc_refs (bfd *, asection *, void *);
@ -387,7 +387,7 @@ check_local_sym_xref (lang_input_statement_type *statement)
for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next) for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next)
for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next) for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next)
if (strcmp (ncr->name, outsecname) == 0) if (strcmp (ncr->name, outsecname) == 0)
check_refs (symname, sym->section, abfd, ncrs); check_refs (symname, FALSE, sym->section, abfd, ncrs);
} }
} }
@ -429,7 +429,8 @@ check_nocrossref (struct cref_hash_entry *h, void *ignore ATTRIBUTE_UNUSED)
for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next) for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next)
if (strcmp (ncr->name, defsecname) == 0) if (strcmp (ncr->name, defsecname) == 0)
for (ref = h->refs; ref != NULL; ref = ref->next) for (ref = h->refs; ref != NULL; ref = ref->next)
check_refs (hl->root.string, hl->u.def.section, ref->abfd, ncrs); check_refs (hl->root.string, TRUE, hl->u.def.section,
ref->abfd, ncrs);
return TRUE; return TRUE;
} }
@ -442,6 +443,7 @@ struct check_refs_info {
asection *defsec; asection *defsec;
struct lang_nocrossrefs *ncrs; struct lang_nocrossrefs *ncrs;
asymbol **asymbols; asymbol **asymbols;
bfd_boolean global;
}; };
/* This function is called for each symbol defined in a section which /* This function is called for each symbol defined in a section which
@ -451,6 +453,7 @@ struct check_refs_info {
static void static void
check_refs (const char *name, check_refs (const char *name,
bfd_boolean global,
asection *sec, asection *sec,
bfd *abfd, bfd *abfd,
struct lang_nocrossrefs *ncrs) struct lang_nocrossrefs *ncrs)
@ -488,6 +491,7 @@ check_refs (const char *name,
} }
info.sym_name = name; info.sym_name = name;
info.global = global;
info.defsec = sec; info.defsec = sec;
info.ncrs = ncrs; info.ncrs = ncrs;
info.asymbols = asymbols; info.asymbols = asymbols;
@ -513,6 +517,7 @@ check_reloc_refs (bfd *abfd, asection *sec, void *iarg)
const char *outdefsecname; const char *outdefsecname;
struct lang_nocrossref *ncr; struct lang_nocrossref *ncr;
const char *symname; const char *symname;
bfd_boolean global;
long relsize; long relsize;
arelent **relpp; arelent **relpp;
long relcount; long relcount;
@ -538,9 +543,13 @@ check_reloc_refs (bfd *abfd, asection *sec, void *iarg)
/* This section is one for which cross references are prohibited. /* This section is one for which cross references are prohibited.
Look through the relocations, and see if any of them are to Look through the relocations, and see if any of them are to
INFO->SYM_NAME. If INFO->SYMNAME is NULL, check for relocations INFO->SYM_NAME. If INFO->SYMNAME is NULL, check for relocations
against the section symbol. */ against the section symbol. If INFO->GLOBAL is TRUE, the
definition is global, check for relocations against the global
symbols. Otherwise check for relocations against the local and
section symbols. */
symname = info->sym_name; symname = info->sym_name;
global = info->global;
relsize = bfd_get_reloc_upper_bound (abfd, sec); relsize = bfd_get_reloc_upper_bound (abfd, sec);
if (relsize < 0) if (relsize < 0)
@ -561,6 +570,14 @@ check_reloc_refs (bfd *abfd, asection *sec, void *iarg)
if (q->sym_ptr_ptr != NULL if (q->sym_ptr_ptr != NULL
&& *q->sym_ptr_ptr != NULL && *q->sym_ptr_ptr != NULL
&& ((global
&& (bfd_is_und_section (bfd_get_section (*q->sym_ptr_ptr))
|| bfd_is_com_section (bfd_get_section (*q->sym_ptr_ptr))
|| ((*q->sym_ptr_ptr)->flags & (BSF_GLOBAL
| BSF_WEAK)) != 0))
|| (!global
&& ((*q->sym_ptr_ptr)->flags & (BSF_LOCAL
| BSF_SECTION_SYM)) != 0))
&& (symname != NULL && (symname != NULL
? strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0 ? strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0
: (((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0 : (((*q->sym_ptr_ptr)->flags & BSF_SECTION_SYM) != 0

View file

@ -339,7 +339,7 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning)
&& strcmp (last_file, filename) != 0) && strcmp (last_file, filename) != 0)
|| strcmp (last_function, functionname) != 0) || strcmp (last_function, functionname) != 0)
{ {
lfinfo (fp, _("%B: In function `%T':\n"), lfinfo (fp, _("%B: In function `%T'"),
abfd, functionname); abfd, functionname);
last_bfd = abfd; last_bfd = abfd;
@ -355,19 +355,19 @@ vfinfo (FILE *fp, const char *fmt, va_list arg, bfd_boolean is_warning)
discard_last = FALSE; discard_last = FALSE;
} }
else else
lfinfo (fp, "%B:", abfd); lfinfo (fp, "%B", abfd);
if (filename != NULL) if (filename != NULL)
fprintf (fp, "%s:", filename); fprintf (fp, ":%s", filename);
if (functionname != NULL && fmt[-1] == 'G') if (functionname != NULL && fmt[-1] == 'G')
lfinfo (fp, "%T", functionname); lfinfo (fp, ":%T", functionname);
else if (filename != NULL) else if (filename != NULL)
{ {
if (linenumber != 0) if (linenumber != 0)
fprintf (fp, "%u", linenumber); fprintf (fp, ":%u", linenumber);
else else
lfinfo (fp, "(%A+0x%v)", section, offset); lfinfo (fp, ":(%A+0x%v)", section, offset);
} }
} }
else else