aboutsummaryrefslogtreecommitdiff
path: root/ld/ldcref.c
diff options
context:
space:
mode:
authorMatthew Fortune <matthew.fortune@imgtec.com>2016-04-14 11:49:53 +0100
committerMatthew Fortune <matthew.fortune@imgtec.com>2016-04-18 12:45:46 +0100
commitcdf969539c718acb1f3f031b2c55d5274a538717 (patch)
tree003ffa5726fcc2217dc4aafcdeb1efa46ff88b04 /ld/ldcref.c
parent5947319ef398728052a22575e1d0de0e94e4220f (diff)
downloadgdb-cdf969539c718acb1f3f031b2c55d5274a538717.zip
gdb-cdf969539c718acb1f3f031b2c55d5274a538717.tar.gz
gdb-cdf969539c718acb1f3f031b2c55d5274a538717.tar.bz2
Add new NOCROSSREFS_TO linker script command
NOCROSSREFS_TO is similar to the existing NOCROSSREFS command but only checks one direction of cross referencing. ld/ChangeLog * ld.texinfo: Document NOCROSSREFS_TO script command. * ldlang.h (struct lang_nocrossrefs): Add onlyfirst field. (lang_add_nocrossref_to): New prototype. * ldcref.c (check_local_sym_xref): Use onlyfirst to only look for symbols defined in the first section. (check_nocrossref): Likewise. * ldgram.y (NOCROSSREFS_TO): New script command. * ldlang.c (lang_add_nocrossref): Set onlyfirst to FALSE. (lang_add_nocrossref_to): New function. * ldlex.l (NOCROSSREFS_TO): New token. * NEWS: Mention NOCROSSREFS_TO. * testsuite/ld-scripts/cross4.t: New file. * testsuite/ld-scripts/cross5.t: Likewise. * testsuite/ld-scripts/cross6.t: Likewise. * testsuite/ld-scripts/cross7.t: Likewise. * testsuite/ld-scripts/crossref.exp: Run 4 new NOCROSSREFS_TO tests.
Diffstat (limited to 'ld/ldcref.c')
-rw-r--r--ld/ldcref.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/ld/ldcref.c b/ld/ldcref.c
index b87f384..d96db20 100644
--- a/ld/ldcref.c
+++ b/ld/ldcref.c
@@ -534,8 +534,14 @@ check_local_sym_xref (lang_input_statement_type *statement)
symname = sym->name;
for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next)
for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next)
- if (strcmp (ncr->name, outsecname) == 0)
- check_refs (symname, FALSE, sym->section, abfd, ncrs);
+ {
+ if (strcmp (ncr->name, outsecname) == 0)
+ check_refs (symname, FALSE, sym->section, abfd, ncrs);
+ /* The NOCROSSREFS_TO command only checks symbols defined in
+ the first section in the list. */
+ if (ncrs->onlyfirst)
+ break;
+ }
}
}
}
@@ -572,10 +578,16 @@ check_nocrossref (struct cref_hash_entry *h, void *ignore ATTRIBUTE_UNUSED)
for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next)
for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next)
- if (strcmp (ncr->name, defsecname) == 0)
- for (ref = h->refs; ref != NULL; ref = ref->next)
- check_refs (hl->root.string, TRUE, hl->u.def.section,
- ref->abfd, ncrs);
+ {
+ if (strcmp (ncr->name, defsecname) == 0)
+ for (ref = h->refs; ref != NULL; ref = ref->next)
+ check_refs (hl->root.string, TRUE, hl->u.def.section,
+ ref->abfd, ncrs);
+ /* The NOCROSSREFS_TO command only checks symbols defined in the first
+ section in the list. */
+ if (ncrs->onlyfirst)
+ break;
+ }
return TRUE;
}