@@ -105,6 +105,9 @@ typedef struct def_file {
/* From EXCLUDE_SYMBOLS or embedded directives. */
def_file_symbol_list exclude_symbols;
+
+ /* From UNDEFINED, INCLUDE or embedded directives. */
+ def_file_symbol_list undefined_symbols;
} def_file;
extern def_file *def_file_empty (void);
@@ -104,6 +104,8 @@ static void def_version (int, int);
static void def_directive (char *);
static void def_aligncomm (char *str, int align);
static void def_exclude_symbols (char *str);
+static void def_undefined (char *str);
+static void def_include (char *str);
static int def_parse (void);
static void def_error (const char *);
static int def_lex (void);
@@ -124,7 +126,7 @@ static const char *lex_parse_string_end = 0;
%token NAME LIBRARY DESCRIPTION STACKSIZE_K HEAPSIZE CODE DATAU DATAL
%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANTU CONSTANTL
-%token PRIVATEU PRIVATEL ALIGNCOMM EXCLUDE_SYMBOLS
+%token PRIVATEU PRIVATEL ALIGNCOMM EXCLUDE_SYMBOLS INCLUDE UNDEFINED
%token READ WRITE EXECUTE SHARED_K NONAMEU NONAMEL DIRECTIVE EQUAL
%token <id> ID
%token <digits> DIGITS
@@ -159,6 +161,8 @@ command:
| DIRECTIVE ID { def_directive ($2);}
| ALIGNCOMM anylang_id ',' NUMBER { def_aligncomm ($2, $4);}
| EXCLUDE_SYMBOLS symbol_list
+ | INCLUDE inclist
+ | UNDEFINED undlist
;
@@ -256,6 +260,7 @@ keyword_as_name: BASE { $$ = "BASE"; }
| EXPORTS { $$ = "EXPORTS"; }
| HEAPSIZE { $$ = "HEAPSIZE"; }
| IMPORTS { $$ = "IMPORTS"; }
+ | INCLUDE { $$ = "INCLUDE"; }
/* Disable LIBRARY keyword as valid symbol-name. This is necessary
for libtool, which places this command after EXPORTS command.
This behavior is illegal by specification, but sadly required by
@@ -270,6 +275,7 @@ keyword_as_name: BASE { $$ = "BASE"; }
| READ { $$ = "READ"; }
| SHARED_K { $$ = "SHARED"; }
| STACKSIZE_K { $$ = "STACKSIZE"; }
+ | UNDEFINED { $$ = "UNDEFINED"; }
| VERSIONK { $$ = "VERSION"; }
| WRITE { $$ = "WRITE"; }
;
@@ -344,6 +350,18 @@ symbol_list:
| symbol_list ',' anylang_id { def_exclude_symbols ($3); }
;
+undlist:
+ anylang_id { def_undefined ($1); }
+ | undlist anylang_id { def_undefined ($2); }
+ | undlist ',' anylang_id { def_undefined ($3); }
+ ;
+
+inclist:
+ anylang_id { def_include ($1); }
+ | inclist anylang_id { def_include ($2); }
+ | inclist ',' anylang_id { def_include ($3); }
+ ;
+
opt_digits: DIGITS { $$ = $1; }
| { $$ = ""; }
;
@@ -496,6 +514,7 @@ def_file_free (def_file *fdef)
}
symbol_list_clear (&fdef->exclude_symbols);
+ symbol_list_clear (&fdef->undefined_symbols);
free (fdef);
}
@@ -1056,6 +1075,13 @@ def_file_add_exclude_symbol (def_file *fdef,
symbol_list_add (&fdef->exclude_symbols, name);
}
+static void
+def_file_add_undefined_symbol (def_file *fdef,
+ const char *name)
+{
+ symbol_list_add (&fdef->undefined_symbols, name);
+}
+
struct
{
char *param;
@@ -1069,6 +1095,8 @@ diropts[] =
{ "-export", EXPORTS },
{ "-aligncomm", ALIGNCOMM },
{ "-exclude-symbols", EXCLUDE_SYMBOLS },
+ { "-include", INCLUDE },
+ { "-undefined", UNDEFINED },
{ 0, 0 }
};
@@ -1387,6 +1415,19 @@ def_exclude_symbols (char *str)
def_file_add_exclude_symbol (def, str);
}
+static void
+def_undefined (char *str)
+{
+ def_file_add_undefined_symbol (def, str);
+}
+
+static void
+def_include (char *str)
+{
+ /* include is an alias for undefined */
+ def_undefined (str);
+}
+
static void
def_error (const char *err)
{
@@ -1437,6 +1478,7 @@ tokens[] =
{ "EXPORTS", EXPORTS },
{ "HEAPSIZE", HEAPSIZE },
{ "IMPORTS", IMPORTS },
+ { "INCLUDE", INCLUDE },
{ "LIBRARY", LIBRARY },
{ "NAME", NAME },
{ "NONAME", NONAMEU },
@@ -1448,6 +1490,7 @@ tokens[] =
{ "SEGMENTS", SECTIONS },
{ "SHARED", SHARED_K },
{ "STACKSIZE", STACKSIZE_K },
+ { "UNDEFINED", UNDEFINED },
{ "VERSION", VERSIONK },
{ "WRITE", WRITE },
{ 0, 0 }
@@ -784,6 +784,9 @@ process_def_file_and_drectve (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *
for (ui = 0; ui < pe_def_file->exclude_symbols.count; ui++)
pe_dll_add_excludes (pe_def_file->exclude_symbols.array[ui], EXCLUDESYMS);
+ for (ui = 0; ui < pe_def_file->undefined_symbols.count; ui++)
+ lang_add_gc_name (pe_def_file->undefined_symbols.array[ui]);
+
/* If we are building an executable and there is nothing
to export, we do not build an export table at all. */
if (bfd_link_executable (info) && pe_def_file->num_exports == 0
@@ -177,6 +177,10 @@ 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"
+run_dump_test "undefined-embedded-i386"
+run_dump_test "undefined-embedded-x86_64"
+run_dump_test "undefined-def-i386"
+run_dump_test "undefined-def-x86_64"
if [check_shared_lib_support] {
set old_ASFLAGS $ASFLAGS
new file mode 100755
@@ -0,0 +1,16 @@
+#source: undefined-def-i386.s
+#target: i?86-*-cygwin* i?86-*-pe i?86-*-mingw*
+#ld: --gc-sections -shared ${srcdir}/${subdir}/undefined-def-i386.def
+#objdump: -h
+
+#not .*sym3.*
+#...
+Sections:
+Idx Name.*
+\s+\d+ export1 .*
+^.*$
+\s+\d+ sym1 .*
+^.*$
+\s+\d+ sym2 .*
+^.*$
+#pass
new file mode 100755
@@ -0,0 +1,4 @@
+LIBRARY undefined-def.dll
+UNDEFINED
+_sym1
+_sym2
new file mode 100755
@@ -0,0 +1,19 @@
+.global _export1
+.global _sym1
+.global _sym2
+.global _sym3
+.section export1,"xr"
+_export1:
+ ret
+.section sym1,"xr"
+_sym1:
+ ret
+.section sym2,"xr"
+_sym2:
+ ret
+.section sym3,"xr"
+_sym3:
+ ret
+
+.section .drectve,"yn"
+.ascii " -export:export1"
new file mode 100755
@@ -0,0 +1,16 @@
+#source: undefined-def-x86_64.s
+#target: x86_64-*-cygwin* x86_64-*-pe x86_64-*-mingw*
+#ld: --gc-sections -shared ${srcdir}/${subdir}/undefined-def-x86_64.def
+#objdump: -h
+
+#not .*sym3.*
+#...
+Sections:
+Idx Name.*
+\s+\d+ export1 .*
+^.*$
+\s+\d+ sym1 .*
+^.*$
+\s+\d+ sym2 .*
+^.*$
+#pass
new file mode 100755
@@ -0,0 +1,4 @@
+LIBRARY undefined-def.dll
+UNDEFINED
+sym1
+sym2
new file mode 100755
@@ -0,0 +1,19 @@
+.global export1
+.global sym1
+.global sym2
+.global sym3
+.section export1,"xr"
+export1:
+ ret
+.section sym1,"xr"
+sym1:
+ ret
+.section sym2,"xr"
+sym2:
+ ret
+.section sym3,"xr"
+sym3:
+ ret
+
+.section .drectve,"yn"
+.ascii " -export:export1"
new file mode 100755
@@ -0,0 +1,16 @@
+#source: undefined-embedded-i386.s
+#target: i?86-*-cygwin* i?86-*-pe i?86-*-mingw*
+#ld: --gc-sections -shared
+#objdump: -h
+
+#not .*sym3.*
+#...
+Sections:
+Idx Name.*
+\s+\d+ export1 .*
+^.*$
+\s+\d+ sym1 .*
+^.*$
+\s+\d+ sym2 .*
+^.*$
+#pass
new file mode 100755
@@ -0,0 +1,21 @@
+.global _export1
+.global _sym1
+.global _sym2
+.global _sym3
+.section export1,"xr"
+_export1:
+ ret
+.section sym1,"xr"
+_sym1:
+ ret
+.section sym2,"xr"
+_sym2:
+ ret
+.section sym3,"xr"
+_sym3:
+ ret
+
+.section .drectve,"yn"
+.ascii " -export:export1"
+.ascii " -undefined:_sym1,_unknownsym"
+.ascii " -include:_unknownsym,_sym2"
new file mode 100755
@@ -0,0 +1,16 @@
+#source: undefined-embedded-x86_64.s
+#target: x86_64-*-cygwin* x86_64-*-pe x86_64-*-mingw*
+#ld: --gc-sections -shared
+#objdump: -h
+
+#not .*sym3.*
+#...
+Sections:
+Idx Name.*
+\s+\d+ export1 .*
+^.*$
+\s+\d+ sym1 .*
+^.*$
+\s+\d+ sym2 .*
+^.*$
+#pass
new file mode 100755
@@ -0,0 +1,21 @@
+.global export1
+.global sym1
+.global sym2
+.global sym3
+.section export1,"xr"
+export1:
+ ret
+.section sym1,"xr"
+sym1:
+ ret
+.section sym2,"xr"
+sym2:
+ ret
+.section sym3,"xr"
+sym3:
+ ret
+
+.section .drectve,"yn"
+.ascii " -export:export1"
+.ascii " -undefined:sym1,unknownsym"
+.ascii " -include:unknownsym,sym2"