diff options
author | Cary Coutant <ccoutant@gmail.com> | 2018-04-23 09:27:35 -0700 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2018-04-24 13:51:24 -0700 |
commit | 890d155592e66dc01fc4a9affba806c4e9fc36ba (patch) | |
tree | 0ccfa6f963c937ec8f5648ecb9d401ae676c0778 /gold/testsuite/plugin_test.c | |
parent | f67c0c9171508672167b6868c67211571421a1c6 (diff) | |
download | binutils-890d155592e66dc01fc4a9affba806c4e9fc36ba.zip binutils-890d155592e66dc01fc4a9affba806c4e9fc36ba.tar.gz binutils-890d155592e66dc01fc4a9affba806c4e9fc36ba.tar.bz2 |
Fix internal error caused by conflicting default version definitions.
gold/
PR gold/16504
* dynobj.cc (Versions::symbol_section_contents): Don't set
VERSYM_HIDDEN flag for undefined symbols.
* symtab.cc (Symbol_table::add_from_object): Don't override default
version definition with a different default version.
* symtab.h (Symbol::from_dyn): New method.
* testsuite/plugin_test.c (struct sym_info): Add ver field.
(claim_file_hook): Pass symbol version to plugin API.
(parse_readelf_line): Parse symbol version.
* testsuite/Makefile.am (ver_test_pr16504): New test case.
* testsuite/Makefile.in: Regenerate.
* testsuite/ver_test_pr16504.sh: New test script.
* testsuite/ver_test_pr16504_a.c: New source file.
* testsuite/ver_test_pr16504_a.script: New version script.
* testsuite/ver_test_pr16504_b.c: New source file.
* testsuite/ver_test_pr16504_b.script: New version script.
Diffstat (limited to 'gold/testsuite/plugin_test.c')
-rw-r--r-- | gold/testsuite/plugin_test.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/gold/testsuite/plugin_test.c b/gold/testsuite/plugin_test.c index e80f926..a21abca 100644 --- a/gold/testsuite/plugin_test.c +++ b/gold/testsuite/plugin_test.c @@ -46,6 +46,7 @@ struct sym_info char* vis; char* sect; char* name; + char* ver; }; static struct claimed_file* first_claimed_file = NULL; @@ -397,7 +398,14 @@ claim_file_hook (const struct ld_plugin_input_file* file, int* claimed) syms[nsyms].name = malloc(len + 1); strncpy(syms[nsyms].name, info.name, len + 1); } - syms[nsyms].version = NULL; + if (info.ver == NULL) + syms[nsyms].version = NULL; + else + { + len = strlen(info.ver); + syms[nsyms].version = malloc(len + 1); + strncpy(syms[nsyms].version, info.ver, len + 1); + } syms[nsyms].def = def; syms[nsyms].visibility = vis; syms[nsyms].size = info.size; @@ -676,11 +684,26 @@ parse_readelf_line(char* p, struct sym_info* info) p += strspn(p, " "); /* Name field. */ - /* FIXME: Look for version. */ - len = strlen(p); - if (len == 0) - p = NULL; - else if (p[len-1] == '\n') - p[--len] = '\0'; - info->name = p; + len = strcspn(p, "@\n"); + if (len > 0 && p[len] == '@') + { + /* Get the symbol version. */ + char* vp = p + len; + int vlen; + + vp += strspn(vp, "@"); + vlen = strcspn(vp, "\n"); + vp[vlen] = '\0'; + if (vlen > 0) + info->ver = vp; + else + info->ver = NULL; + } + else + info->ver = NULL; + p[len] = '\0'; + if (len > 0) + info->name = p; + else + info->name = NULL; } |