[RFA:] Ignore --gc-sections if non-ELF objects are involved
Hans-Peter Nilsson
hans-peter.nilsson@axis.com
Mon Mar 25 15:15:00 GMT 2002
The test currently SEGV:s. It's better if GC just isn't
performed, as happens if !get_elf_backend_data (abfd)->can_gc_sections
or info->dynamic_sections_created.
Ok to commit?
bfd:
* elflink.h (elf_gc_sections): Check that all input BFD:s are ELF.
ld/testsuite:
* ld-cris/aoutnondso-1.d, ld-cris/aout-1.d, ld-cris/expfnref1.s:
New test.
Index: elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.152
diff -p -c -r1.152 elflink.h
*** elflink.h 2002/03/19 20:21:54 1.152
--- elflink.h 2002/03/25 22:32:40
*************** elf_gc_sections (abfd, info)
*** 7809,7814 ****
--- 7809,7820 ----
|| elf_hash_table (info)->dynamic_sections_created)
return true;
+ /* Check that we're dealing only with ELF files. If not, just ignore
+ the GC request. */
+ for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+ if (bfd_get_flavour (sub) != bfd_target_elf_flavour)
+ return true;
+
/* Apply transitive closure to the vtable entry usage info. */
elf_link_hash_traverse (elf_hash_table (info),
elf_gc_propagate_vtable_entries_used,
*** /dev/null Tue Jan 1 05:00:00 1980
--- aoutnondso-1.d Mon Mar 25 22:29:14 2002
***************
*** 0 ****
--- 1,8 ----
+ #source: expdyn1.s
+ #as: --em=crisaout
+ #ld: -mcrisaout -r
+ #objdump: -p
+
+ # Prepare a.out object to be linked in to other tests.
+
+ .*: file format a.out-cris
*** /dev/null Tue Jan 1 05:00:00 1980
--- aout-1.d Mon Mar 25 23:53:36 2002
***************
*** 0 ****
--- 1,32 ----
+ #source: expfnref1.s
+ #as: --em=criself
+ #ld: --gc-sections -m criself tmpdir/aoutnondso-1.so
+ #objdump: -str
+
+ # Check that --gc-sections and linking an ELF and an a.out "work";
+ # i.e. that the GC request is just ignored. No SEGV or such.
+
+ .*: file format elf32-us-cris
+
+ SYMBOL TABLE:
+ #...
+ 0+ g \.startup 0+ x
+ #...
+ 0+e g \.text 0+ expfn
+ #...
+ 0+40 g \.data 0+ expobj
+ #...
+ 0+ g \.startup 0+ __Stext
+
+ Contents of section \.startup:
+ 0000 3fbd0e00 0000 .*
+ Contents of section \.init:
+ 0006 fce17ebe 3e0d .*
+ Contents of section .text:
+ 000c 0f050f05 .*
+ Contents of section .fini:
+ 0010 fce17ebe 3e0d .*
+ Contents of section \.data:
+ 0040 00000000 .*
+ Contents of section \.ctors:
+ Contents of section \.dtors:
*** /dev/null Tue Jan 1 05:00:00 1980
--- expfnref1.s Mon Mar 25 22:41:44 2002
***************
*** 0 ****
--- 1,4 ----
+ .section .startup,"ax"
+ .global x
+ x:
+ jsr expfn
brgds, H-P
More information about the Binutils
mailing list