aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-07-26 05:59:55 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-07-28 06:01:32 -0700
commit5a98fb7513b559e20dfebdbaa2a471afda3b4742 (patch)
tree9afa418dac0808e77bfa34eaa1fe719b08e4725e /ld
parent265dcb69c2ec6e9f24f40cb25349534e44360098 (diff)
downloadgdb-5a98fb7513b559e20dfebdbaa2a471afda3b4742.zip
gdb-5a98fb7513b559e20dfebdbaa2a471afda3b4742.tar.gz
gdb-5a98fb7513b559e20dfebdbaa2a471afda3b4742.tar.bz2
bfd: Close the file descriptor if there is no archive fd
Close the file descriptor if there is no archive plugin file descriptor to avoid running out of file descriptors on thin archives with many archive members. bfd/ PR ld/28138 * plugin.c (bfd_plugin_close_file_descriptor): Close the file descriptor there is no archive plugin file descriptor. ld/ PR ld/28138 * testsuite/ld-plugin/lto.exp: Run ld/28138 tests. * testsuite/ld-plugin/pr28138.c: New file. * testsuite/ld-plugin/pr28138-1.c: Likewise. * testsuite/ld-plugin/pr28138-2.c: Likewise. * testsuite/ld-plugin/pr28138-3.c: Likewise. * testsuite/ld-plugin/pr28138-4.c: Likewise. * testsuite/ld-plugin/pr28138-5.c: Likewise. * testsuite/ld-plugin/pr28138-6.c: Likewise. * testsuite/ld-plugin/pr28138-7.c: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ld-plugin/lto.exp30
-rw-r--r--ld/testsuite/ld-plugin/pr28138-1.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138-2.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138-3.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138-4.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138-5.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138-6.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138-7.c6
-rw-r--r--ld/testsuite/ld-plugin/pr28138.c20
9 files changed, 92 insertions, 0 deletions
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index def69e4..63be062 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -930,4 +930,34 @@ if { [check_lto_fat_available] } {
}
}
+run_cc_link_tests [list \
+ [list \
+ "Build pr28138.a" \
+ "-T" "" \
+ {pr28138-1.c pr28138-2.c pr28138-3.c pr28138-4.c pr28138-5.c \
+ pr28138-6.c pr28138-7.c} {} "pr28138.a" \
+ ] \
+ [list \
+ "Build pr28138.o" \
+ "" "" \
+ {pr28138.c} {} \
+ ] \
+]
+
+set exec_output [run_host_cmd "sh" \
+ "-c \"ulimit -n 20; \
+ $CC -Btmpdir/ld -o tmpdir/pr28138 \
+ tmpdir/pr28138.o tmpdir/pr28138.a\""]
+set exec_output [prune_warnings $exec_output]
+if [string match "" $exec_output] then {
+ set exec_output [run_host_cmd "tmpdir/pr28138" ""]
+ if [string match "PASS" $exec_output] then {
+ pass "PR ld/28138"
+ } else {
+ fail "PR ld/28138"
+ }
+} else {
+ fail "PR ld/28138"
+}
+
restore_notify
diff --git a/ld/testsuite/ld-plugin/pr28138-1.c b/ld/testsuite/ld-plugin/pr28138-1.c
new file mode 100644
index 0000000..51d119e
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-1.c
@@ -0,0 +1,6 @@
+extern int a0(void);
+int
+a1(void)
+{
+ return 1 + a0();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-2.c b/ld/testsuite/ld-plugin/pr28138-2.c
new file mode 100644
index 0000000..1120cd7
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-2.c
@@ -0,0 +1,6 @@
+extern int a1(void);
+int
+a2(void)
+{
+ return 1 + a1();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-3.c b/ld/testsuite/ld-plugin/pr28138-3.c
new file mode 100644
index 0000000..ec46494
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-3.c
@@ -0,0 +1,6 @@
+extern int a2(void);
+int
+a3(void)
+{
+ return 1 + a2();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-4.c b/ld/testsuite/ld-plugin/pr28138-4.c
new file mode 100644
index 0000000..475701b
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-4.c
@@ -0,0 +1,6 @@
+extern int a3(void);
+int
+a4(void)
+{
+ return 1 + a3();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-5.c b/ld/testsuite/ld-plugin/pr28138-5.c
new file mode 100644
index 0000000..e24f86c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-5.c
@@ -0,0 +1,6 @@
+extern int a4(void);
+int
+a5(void)
+{
+ return 1 + a4();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-6.c b/ld/testsuite/ld-plugin/pr28138-6.c
new file mode 100644
index 0000000..b5b938b
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-6.c
@@ -0,0 +1,6 @@
+extern int a5(void);
+int
+a6(void)
+{
+ return 1 + a5();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138-7.c b/ld/testsuite/ld-plugin/pr28138-7.c
new file mode 100644
index 0000000..4ef75bf
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138-7.c
@@ -0,0 +1,6 @@
+extern int a6(void);
+int
+a7(void)
+{
+ return 1 + a6();
+}
diff --git a/ld/testsuite/ld-plugin/pr28138.c b/ld/testsuite/ld-plugin/pr28138.c
new file mode 100644
index 0000000..68252c9
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr28138.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+extern int a7(void);
+
+int
+a0(void)
+{
+ return 0;
+}
+
+int
+main()
+{
+ if (a7() == 7)
+ {
+ printf ("PASS\n");
+ return 0;
+ }
+ return 1;
+}