public inbox for binutils-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Storsjo <mstorsjo@sourceware.org> To: bfd-cvs@sourceware.org Subject: [binutils-gdb] ld: Support the -exclude-symbols option via COFF def files, with the EXCLUDE_SYMBOLS keyword Date: Mon, 1 Aug 2022 20:23:39 +0000 (GMT) [thread overview] Message-ID: <20220801202339.89AE7385802B@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=61f6b650f9bb7fd276b45427b9202f3263465376 commit 61f6b650f9bb7fd276b45427b9202f3263465376 Author: Martin Storsjö <martin@martin.st> Date: Sat Jul 23 00:57:19 2022 +0300 ld: Support the -exclude-symbols option via COFF def files, with the EXCLUDE_SYMBOLS keyword This was requested in review. Diff: --- ld/deffile.h | 2 ++ ld/deffilep.y | 3 +++ ld/testsuite/ld-pe/exclude-symbols-def-i386.d | 10 ++++++++++ ld/testsuite/ld-pe/exclude-symbols-def-i386.s | 11 +++++++++++ ld/testsuite/ld-pe/exclude-symbols-def-x86_64.d | 10 ++++++++++ ld/testsuite/ld-pe/exclude-symbols-def-x86_64.s | 11 +++++++++++ ld/testsuite/ld-pe/exclude-symbols-def.def | 4 ++++ ld/testsuite/ld-pe/pe.exp | 2 ++ 8 files changed, 53 insertions(+) diff --git a/ld/deffile.h b/ld/deffile.h index 306ae3a6f75..a247639628e 100644 --- a/ld/deffile.h +++ b/ld/deffile.h @@ -99,6 +99,8 @@ typedef struct def_file { /* Only expected from .drectve sections, not .DEF files. */ def_file_aligncomm *aligncomms; + + /* From EXCLUDE_SYMBOLS or embedded directives. */ def_file_exclude_symbol *exclude_symbols; } def_file; diff --git a/ld/deffilep.y b/ld/deffilep.y index dc0cb4db944..27db336e0f5 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -249,6 +249,7 @@ keyword_as_name: BASE { $$ = "BASE"; } | DATAL { $$ = "data"; } | DESCRIPTION { $$ = "DESCRIPTION"; } | DIRECTIVE { $$ = "DIRECTIVE"; } + | EXCLUDE_SYMBOLS { $$ = "EXCLUDE_SYMBOLS"; } | EXECUTE { $$ = "EXECUTE"; } | EXPORTS { $$ = "EXPORTS"; } | HEAPSIZE { $$ = "HEAPSIZE"; } @@ -337,6 +338,7 @@ anylang_id: ID { $$ = $1; } symbol_list: anylang_id { def_exclude_symbols ($1); } + | symbol_list anylang_id { def_exclude_symbols ($2); } | symbol_list ',' anylang_id { def_exclude_symbols ($3); } ; @@ -1352,6 +1354,7 @@ tokens[] = { "data", DATAL }, { "DESCRIPTION", DESCRIPTION }, { "DIRECTIVE", DIRECTIVE }, + { "EXCLUDE_SYMBOLS", EXCLUDE_SYMBOLS }, { "EXECUTE", EXECUTE }, { "EXPORTS", EXPORTS }, { "HEAPSIZE", HEAPSIZE }, diff --git a/ld/testsuite/ld-pe/exclude-symbols-def-i386.d b/ld/testsuite/ld-pe/exclude-symbols-def-i386.d new file mode 100644 index 00000000000..1f15c893447 --- /dev/null +++ b/ld/testsuite/ld-pe/exclude-symbols-def-i386.d @@ -0,0 +1,10 @@ +#source: exclude-symbols-def-i386.s +#target: i?86-*-cygwin* i?86-*-pe i?86-*-mingw* +#ld: -shared ${srcdir}/${subdir}/exclude-symbols-def.def +#objdump: -p + +#... +.*\[[ ]*0\] sym1 +.*\[[ ]*1\] sym3 +.*\[[ ]*2\] sym5 +#pass diff --git a/ld/testsuite/ld-pe/exclude-symbols-def-i386.s b/ld/testsuite/ld-pe/exclude-symbols-def-i386.s new file mode 100644 index 00000000000..fd533bb44c9 --- /dev/null +++ b/ld/testsuite/ld-pe/exclude-symbols-def-i386.s @@ -0,0 +1,11 @@ +.global _sym1 +.global _sym2 +.global _sym3 +.global _sym4 +.global _sym5 +_sym1: +_sym2: +_sym3: +_sym4: +_sym5: + ret diff --git a/ld/testsuite/ld-pe/exclude-symbols-def-x86_64.d b/ld/testsuite/ld-pe/exclude-symbols-def-x86_64.d new file mode 100644 index 00000000000..39de8813dc5 --- /dev/null +++ b/ld/testsuite/ld-pe/exclude-symbols-def-x86_64.d @@ -0,0 +1,10 @@ +#source: exclude-symbols-def-x86_64.s +#target: x86_64-*-cygwin* x86_64-*-pe x86_64-*-mingw* +#ld: -shared ${srcdir}/${subdir}/exclude-symbols-def.def +#objdump: -p + +#... +.*\[[ ]*0\] sym1 +.*\[[ ]*1\] sym3 +.*\[[ ]*2\] sym5 +#pass diff --git a/ld/testsuite/ld-pe/exclude-symbols-def-x86_64.s b/ld/testsuite/ld-pe/exclude-symbols-def-x86_64.s new file mode 100644 index 00000000000..2889de1c160 --- /dev/null +++ b/ld/testsuite/ld-pe/exclude-symbols-def-x86_64.s @@ -0,0 +1,11 @@ +.global sym1 +.global sym2 +.global sym3 +.global sym4 +.global sym5 +sym1: +sym2: +sym3: +sym4: +sym5: + ret diff --git a/ld/testsuite/ld-pe/exclude-symbols-def.def b/ld/testsuite/ld-pe/exclude-symbols-def.def new file mode 100644 index 00000000000..c0cee7b1e70 --- /dev/null +++ b/ld/testsuite/ld-pe/exclude-symbols-def.def @@ -0,0 +1,4 @@ +LIBRARY exclude-symbols-def.dll +EXCLUDE_SYMBOLS +sym2 +sym4 diff --git a/ld/testsuite/ld-pe/pe.exp b/ld/testsuite/ld-pe/pe.exp index b640b0891f2..22819e0894f 100644 --- a/ld/testsuite/ld-pe/pe.exp +++ b/ld/testsuite/ld-pe/pe.exp @@ -127,3 +127,5 @@ run_ld_link_tests $foreign_sym_test run_dump_test "exclude-symbols-embedded-i386" run_dump_test "exclude-symbols-embedded-x86_64" +run_dump_test "exclude-symbols-def-i386" +run_dump_test "exclude-symbols-def-x86_64"
reply other threads:[~2022-08-01 20:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220801202339.89AE7385802B@sourceware.org \ --to=mstorsjo@sourceware.org \ --cc=bfd-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).