2009-01-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/9676
	* elflink.c (elf_link_add_object_symbols): Update def_dynamic,
	ref_dynamic and dynamic_def fields when setting def_regular
	to 1.

ld/testsuite/

2009-01-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/9676
	* ld-elf/pr9676-1.c: New.
	* ld-elf/pr9676-2.c: Likewiswe.
	* ld-elf/pr9676-3.c: Likewiswe.
	* ld-elf/pr9676-4.c: Likewiswe.
	* ld-elf/pr9676.rd: Likewiswe.

	* ld-elf/shared.exp (build_tests): Add tests for libpr9676-1.a,
	libpr9676-2.a, libpr9676-3.so, libpr9676-4.so and
	libpr9676-4a.so.

	* lib/ld-lib.exp (ar_simple_create): New.
	(run_ld_link_tests): Support archive.
	(run_cc_link_tests): Likewiswe.
This commit is contained in:
H.J. Lu 2009-01-02 16:48:11 +00:00
parent b70b5c14d5
commit d88805311b
12 changed files with 4535 additions and 4381 deletions

File diff suppressed because it is too large Load Diff

3386
bfd/ChangeLog-2008 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4296,7 +4296,15 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
h->ref_regular_nonweak = 1;
}
else
h->def_regular = 1;
{
h->def_regular = 1;
if (h->def_dynamic)
{
h->def_dynamic = 0;
h->ref_dynamic = 1;
h->dynamic_def = 1;
}
}
if (! info->executable
|| h->def_dynamic
|| h->ref_dynamic)

File diff suppressed because it is too large Load Diff

1010
ld/testsuite/ChangeLog-2008 Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
extern int foo (void) __attribute__((section (".gnu.linkonce.t.1"), weak));
int
foo (void)
{
return 1;
}
extern int foo2 (void);
int
bar (void)
{
return foo2 ();
}

View File

@ -0,0 +1,14 @@
extern int foo (void) __attribute__((section (".gnu.linkonce.t.1"), weak,
__visibility__ ("hidden")));
int
foo (void)
{
return 1;
}
int
foo2 (void)
{
return 1;
}

View File

@ -0,0 +1,7 @@
extern int foo (void) __attribute__((section (".gnu.linkonce.t.1"), weak));
int
foo (void)
{
return 1;
}

View File

@ -0,0 +1,9 @@
extern int bar (void);
extern int foo (void);
int
x (void)
{
foo ();
return bar ();
}

View File

@ -0,0 +1,5 @@
Symbol table '\.dynsym' contains [0-9]+ entries:
+Num: +Value +Size Type +Bind +Vis +Ndx Name
#...
+[0-9]+: +[0-9a-f]+ +[0-9a-f]+ +FUNC +LOCAL +HIDDEN +[0-9]+ +foo
#...

View File

@ -129,6 +129,22 @@ set build_tests {
{"Build libfunc1.so"
"-shared" "-fPIC"
{func1.c} {} "libfunc1.so"}
{"Build libpr9676-1.a"
"" "-fPIC"
{pr9676-1.c} {} "libpr9676-1.a"}
{"Build libpr9676-2.a"
"" "-fPIC"
{pr9676-2.c} {} "libpr9676-2.a"}
{"Build libpr9676-3.so"
"-shared" "-fPIC"
{pr9676-3.c} {} "libpr9676-3.so"}
{"Build libpr9676-4.so"
"-shared" "-fPIC"
{pr9676-4.c} {} "libpr9676-4.so"}
{"Build libpr9676-4a.so"
"-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
"-fPIC"
{dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"}
}
set run_tests {

View File

@ -1093,6 +1093,22 @@ proc file_contents { filename } {
return $contents
}
# Create an archive using ar
#
proc ar_simple_create { ar target objects } {
remote_file host delete $target
set exec_output [run_host_cmd "$ar" "rc $target $objects"]
set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then {
send_log "$exec_output\n"
return 1
} else {
return 0
}
}
# List contains test-items with 3 items followed by 2 lists, one item and
# one optional item:
# 0:name 1:ld options 2:assembler options
@ -1108,6 +1124,7 @@ proc run_ld_link_tests { ldtests } {
global ld
global as
global nm
global ar
global objdump
global READELF
global srcdir
@ -1161,10 +1178,21 @@ proc run_ld_link_tests { ldtests } {
continue
}
if ![ld_simple_link $ld $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
if [regexp ".*a$" $binfile] then {
if ![ar_simple_create $ar $binfile "$objfiles"] {
fail $testname
set failed 1
} else {
set failed 0
}
} elseif ![ld_simple_link $ld $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
fail $testname
set failed 1
} else {
set failed 0
}
if { $failed == 0 } {
foreach actionlist $actions {
set action [lindex $actionlist 0]
set progopts [lindex $actionlist 1]
@ -1429,6 +1457,7 @@ proc run_cc_link_tests { ldtests } {
global CXX
global CFLAGS
global CXXFLAGS
global ar
foreach testitem $ldtests {
set testname [lindex $testitem 0]
@ -1466,10 +1495,21 @@ proc run_cc_link_tests { ldtests } {
set cc_cmd $CC
}
if ![ld_simple_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles"] {
if [regexp ".*a$" $binfile] then {
if ![ar_simple_create $ar $binfile "$objfiles"] {
fail $testname
set failed 1
} else {
set failed 0
}
} elseif ![ld_simple_link $cc_cmd $binfile "-L$srcdir/$subdir $ldflags $objfiles"] {
fail $testname
set failed 1
} else {
set failed 0
}
if { $failed == 0 } {
foreach actionlist $actions {
set action [lindex $actionlist 0]
set progopts [lindex $actionlist 1]