Fix possible failure in the AVR linker tests.

* ld-avr/gc-section-debugline.d: Relax regex check for CU.
This commit is contained in:
Senthil Kumar Selvaraj 2016-03-18 09:51:47 +00:00 committed by Nick Clifton
parent e101a78be9
commit 41f46ed9fe
9 changed files with 114 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2016-03-18 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
* ld-avr/gc-section-debugline.d: Relax regex check for CU.
2016-03-15 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19827

View File

@ -563,7 +563,6 @@ set_entry_point (void)
}
else
{
for (i = 0; v[i].entry; i++)
if (v[i].value == pe_subsystem)
break;

View File

@ -6477,7 +6477,6 @@ static void
lang_gc_sections (void)
{
/* Keep all sections so marked in the link script. */
lang_gc_sections_1 (statement_list.head);
/* SEC_EXCLUDE is ignored when doing a relocatable link, except in
@ -6783,9 +6782,30 @@ lang_process (void)
#endif /* ENABLE_PLUGINS */
link_info.gc_sym_list = &entry_symbol;
if (entry_symbol.name == NULL)
link_info.gc_sym_list = ldlang_undef_chain_list_head;
if (link_info.init_function != NULL)
{
link_info.gc_sym_list = ldlang_undef_chain_list_head;
/* entry_symbol is normally initialied by a ENTRY definition in the
linker script or the -e command line option. But if neither of
these have been used, the target specific backend may still have
provided an entry symbol via a call to lang_default_entry()o.
Unfortunately this value will not be processed until lang_end()
is called, long after this function has finished. So detect this
case here and add the target's entry symbol to the list of starting
points for garbage collection resolution. */
if (entry_symbol_default != NULL)
{
struct bfd_sym_chain *sym
= (struct bfd_sym_chain *) stat_alloc (sizeof (*sym));
sym->next = link_info.gc_sym_list;
sym->name = entry_symbol_default;
link_info.gc_sym_list = sym;
}
}
if (link_info.init_function != NULL)
{
struct bfd_sym_chain *sym
= (struct bfd_sym_chain *) stat_alloc (sizeof (*sym));

View File

@ -895,6 +895,7 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
for (i = 0; i < NE; i++)
{
char *name;
name = xmalloc (strlen (pe_def_file->exports[i].internal_name) + 2);
if (pe_details->underscored
&& (*pe_def_file->exports[i].internal_name != '@'))
@ -2790,7 +2791,44 @@ pe_dll_generate_implib (def_file *def, const char *impfilename, struct bfd_link_
/* Don't add PRIVATE entries to import lib. */
if (pe_def_file->exports[i].flag_private)
continue;
def->exports[i].internal_name = def->exports[i].name;
/* PR 19803: If a symbol has been discard due to garbage
collection then do not create any exports for it. */
{
struct coff_link_hash_entry *h;
h = coff_link_hash_lookup (coff_hash_table (info), internal,
FALSE, FALSE, FALSE);
if (h != NULL
/* If the symbol is hidden and undefined then it
has been swept up by garbage collection. */
&& h->symbol_class == C_HIDDEN
&& h->root.u.def.section == bfd_und_section_ptr)
continue;
/* If necessary, check with an underscore prefix as well. */
if (pe_details->underscored && internal[0] != '@')
{
char *name;
name = xmalloc (strlen (internal) + 2);
sprintf (name, "_%s", internal);
h = coff_link_hash_lookup (coff_hash_table (info), name,
FALSE, FALSE, FALSE);
free (name);
if (h != NULL
/* If the symbol is hidden and undefined then it
has been swept up by garbage collection. */
&& h->symbol_class == C_HIDDEN
&& h->root.u.def.section == bfd_und_section_ptr)
continue;
}
}
n = make_one (def->exports + i, outarch,
! (def->exports + i)->flag_data);
n->archive_next = head;

View File

@ -9,7 +9,7 @@
Decoded dump of debug contents of section .debug_line:
CU: .*:
.*:
File name Line number Starting address
per-function-debugline.s 39 0

View File

@ -76,6 +76,20 @@ run_dump_test "longsecn-5"
run_dump_test "orphan"
run_dump_test "orphan_nu"
run_dump_test "pr19803"
set pr19803_dll {
{ "PR 19803: not exporting swept symbols"
"-shared --out-implib dx.dll --gc-sections"
"" "" {pr19803.s}
{{objdump "--syms dx.dll" pr19803.e}}
"a.exe"}
}
# This test is *supposed* to fail. If the symbol defined in pr19803.e is
# found then it was not stripped from the export dll, despite the fact that
# it (should have been) garbage collected from the executable.
setup_xfail *-*-*
run_ld_link_tests $pr19803_dll
if {[istarget x86_64-*-mingw*] } {
run_dump_test "cfi"
} elseif {[istarget i*86-*-cygwin*] || [istarget i*86-*-mingw*] } {

View File

@ -0,0 +1,17 @@
#ld: -shared --out-implib dx.dll.a --gc-sections
#objdump: --syms
#notarget: mcore-* arm-epoc-pe
#
# Check that the target specific entry symbol _DllMainCRTStartup is still
# a defined (sec > 0), public (scl == 2) symbol, even after garbage
# collection.
#
# Check that the symbol _testval is undefined (sec == 0) and hidden
# (scl == 106) in the output. It should have been changed to this state when
# garbage collection was performed.
#...
.*\(sec 0\)\(fl 0x00\)\(ty 0\)\(scl 106\) \(nx 0\) 0x0+000 _testval
#...
.*\(sec 1\)\(fl 0x00\)\(ty 0\)\(scl 2\) \(nx 0\) 0x0+000 .*Startup.*
#pass

View File

@ -0,0 +1,3 @@
#...
.*__imp__testval
#pass

View File

@ -0,0 +1,14 @@
.text
.globl "_DllMainCRTStartup@12"
"_DllMainCRTStartup@12":
.globl _DllMainCRTStartup
_DllMainCRTStartup:
.globl DllMainCRTStartup
DllMainCRTStartup:
nop
.section .rdata,"dr"
.globl _testval
_testval:
.long 1
.long 2