This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Mark _init and _fini for --gc-sections
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Fri, 10 Apr 2015 04:17:57 -0700
- Subject: Re: Mark _init and _fini for --gc-sections
- Authentication-results: sourceware.org; auth=none
- References: <20150410012506 dot GI27812 at bubble dot grove dot modra dot org>
On Thu, Apr 9, 2015 at 6:25 PM, Alan Modra <amodra@gmail.com> wrote:
> gold marks _init and _fini via symbol, ld marks them via section
> (default scripts set .init and .fini section KEEP). This makes it
> possible for people to write their own _init and not bother to put the
> function into the right section.
>
> PR ld/18223
> * ldlang.c (lang_process): Add _init and _fini to gc_sym_list.
>
I checked in this patch to add a testcase.
--
H.J.
---
Subject: [PATCH] Add a testcase for PR ld/18223
PR ld/18223
* ld-gc/gc.exp: Run pr18223.
* ld-gc/pr18223.d: New file.
* ld-gc/pr18223.s: Likewise.
---
ld/testsuite/ChangeLog | 7 +++++++
ld/testsuite/ld-gc/gc.exp | 1 +
ld/testsuite/ld-gc/pr18223.d | 7 +++++++
ld/testsuite/ld-gc/pr18223.s | 6 ++++++
4 files changed, 21 insertions(+)
create mode 100644 ld/testsuite/ld-gc/pr18223.d
create mode 100644 ld/testsuite/ld-gc/pr18223.s
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 8811a86..79bcb6e 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/18223
+ * ld-gc/gc.exp: Run pr18223.
+ * ld-gc/pr18223.d: New file.
+ * ld-gc/pr18223.s: Likewise.
+
2015-04-10 Alan Modra <amodra@gmail.com>
Revert 2015-03-05 H.J. Lu <hongjiu.lu@intel.com>
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 58f3a2a..b2a3450 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -116,6 +116,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
} else {
run_dump_test "personality"
}
+ run_dump_test "pr18223"
}
if { [is_remote host] || [which $CC] != 0 } {
diff --git a/ld/testsuite/ld-gc/pr18223.d b/ld/testsuite/ld-gc/pr18223.d
new file mode 100644
index 0000000..9fd1912
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr18223.d
@@ -0,0 +1,7 @@
+#name: --gc-sections with .text._init
+#ld: --gc-sections -shared
+#nm: -n
+
+#...
+[0-9a-f]+ t +_init
+#...
diff --git a/ld/testsuite/ld-gc/pr18223.s b/ld/testsuite/ld-gc/pr18223.s
new file mode 100644
index 0000000..69af490
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr18223.s
@@ -0,0 +1,6 @@
+ .section .text._init,"ax",%progbits
+ .globl _init
+ .hidden _init
+ .type _init, %function
+_init:
+ .byte 0
--
2.1.0Subject: [PATCH] Add a testcase for PR ld/18223
PR ld/18223
* ld-gc/gc.exp: Run pr18223.
* ld-gc/pr18223.d: New file.
* ld-gc/pr18223.s: Likewise.
---
ld/testsuite/ChangeLog | 7 +++++++
ld/testsuite/ld-gc/gc.exp | 1 +
ld/testsuite/ld-gc/pr18223.d | 7 +++++++
ld/testsuite/ld-gc/pr18223.s | 6 ++++++
4 files changed, 21 insertions(+)
create mode 100644 ld/testsuite/ld-gc/pr18223.d
create mode 100644 ld/testsuite/ld-gc/pr18223.s
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 8811a86..79bcb6e 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/18223
+ * ld-gc/gc.exp: Run pr18223.
+ * ld-gc/pr18223.d: New file.
+ * ld-gc/pr18223.s: Likewise.
+
2015-04-10 Alan Modra <amodra@gmail.com>
Revert 2015-03-05 H.J. Lu <hongjiu.lu@intel.com>
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 58f3a2a..b2a3450 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -116,6 +116,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then {
} else {
run_dump_test "personality"
}
+ run_dump_test "pr18223"
}
if { [is_remote host] || [which $CC] != 0 } {
diff --git a/ld/testsuite/ld-gc/pr18223.d b/ld/testsuite/ld-gc/pr18223.d
new file mode 100644
index 0000000..9fd1912
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr18223.d
@@ -0,0 +1,7 @@
+#name: --gc-sections with .text._init
+#ld: --gc-sections -shared
+#nm: -n
+
+#...
+[0-9a-f]+ t +_init
+#...
diff --git a/ld/testsuite/ld-gc/pr18223.s b/ld/testsuite/ld-gc/pr18223.s
new file mode 100644
index 0000000..69af490
--- /dev/null
+++ b/ld/testsuite/ld-gc/pr18223.s
@@ -0,0 +1,6 @@
+ .section .text._init,"ax",%progbits
+ .globl _init
+ .hidden _init
+ .type _init, %function
+_init:
+ .byte 0
--
2.1.0