# the "as" flags for their corresponding files, and any extra processing
# (e.g. with "ld" and "objcopy") is repeated for each test.
#
+# dlltool: FLAGS
+# Before linking, run dlltool with FLAGS.
+#
# ld: FLAGS
# Link assembled files using FLAGS, in the order of the "source"
# directives, when using multiple files.
global ELFEDIT ELFEDITFLAGS LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS
global OBJDUMP OBJDUMPFLAGS READELF READELFFLAGS STRIP STRIPFLAGS
global SIZE SIZEFLAGS
- global copyfile env runtests srcdir subdir verbose
+ global copyfile env runtests srcdir subdir verbose base_dir
global DT_RELR_LDFLAGS NO_DT_RELR_LDFLAGS
if [string match "*/*" $name] {
set as_final_flags {}
set as_additional_flags {}
set opts(cc) {}
+ set opts(dlltool) {}
set opts(dump) {}
set opts(elfedit) {}
set opts(error) {}
# Allow more substitutions, including tcl functions, for as, ld,
# and cc. Not done in general because extra quoting is needed for glob
# args used for example in binutils-all/remove-relocs-04.d.
- if { $opt_name == "as" || $opt_name == "ld" || $opt_name == "cc" } {
+ if { $opt_name == "as" || $opt_name == "ld" || $opt_name == "ld_after_inputfiles" || $opt_name == "cc" } {
set opt_val [subst $opt_val]
} else {
# Just substitute $srcdir and $subdir
regsub -all {\$srcdir} "$opt_val" "$srcdir" opt_val
regsub -all {\$subdir} "$opt_val" "$subdir" opt_val
+ regsub -all {\$\{srcdir\}} "$opt_val" "$srcdir" opt_val
+ regsub -all {\$\{subdir\}} "$opt_val" "$subdir" opt_val
}
switch -- $opt_name {
}
}
+ # Run dlltool.
+ if { $cmdret == 0 && $opts(dlltool) != "" } {
+ set dlltool [findfile $base_dir/../binutils/dlltool]
+ set cmd "$dlltool -S $AS $opts(dlltool)"
+ send_log "$cmd\n"
+ set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "dump.tmp"]
+ remote_upload host "dump.tmp"
+ append comp_output [prune_warnings [file_contents "dump.tmp"]]
+ remote_file host delete "dump.tmp"
+ remote_file build delete "dump.tmp"
+ set cmdret [lindex $cmdret 0]
+ }
+
# Perhaps link the file(s).
if { $cmdret == 0 && $run_ld } {
set objfile "tmpdir/dump"
#objdump: -p
#...
-.*\[[ ]*0\].*sym1
-.*\[[ ]*1\].*sym3
-.*\[[ ]*2\].*sym5
+.* Ordinal Hint Name
+.*\+base\[ 1\] 0000 sym1
+.*\+base\[ 2\] 0001 sym3
+.*\+base\[ 3\] 0002 sym5
+
#pass
#objdump: -p
#...
-.*\[[ ]*0\].*sym1
-.*\[[ ]*1\].*sym3
-.*\[[ ]*2\].*sym5
+.* Ordinal Hint Name
+.*\+base\[ 1\] 0000 sym1
+.*\+base\[ 2\] 0001 sym3
+.*\+base\[ 3\] 0002 sym5
+
#pass
#objdump: -p
#...
-.*\[[ ]*0\].*sym1
-.*\[[ ]*1\].*sym3
-.*\[[ ]*2\].*sym5
+.* Ordinal Hint Name
+.*\+base\[ 1\] 0000 sym1
+.*\+base\[ 2\] 0001 sym3
+.*\+base\[ 3\] 0002 sym5
+
#pass
#objdump: -p
#...
-.*\[[ ]*0\].*sym1
-.*\[[ ]*1\].*sym3
-.*\[[ ]*2\].*sym5
+.* Ordinal Hint Name
+.*\+base\[ 1\] 0000 sym1
+.*\+base\[ 2\] 0001 sym3
+.*\+base\[ 3\] 0002 sym5
+
#pass
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 "symbols-ordinals-hints-exports-ld"
+run_dump_test "symbols-ordinals-hints-exports-dlltool"
+run_dump_test "symbols-ordinals-hints-imports-ld"
+run_dump_test "symbols-ordinals-hints-imports-dlltool"
--- /dev/null
+.global _func
+_func:
+ call __imp__sym1
+ call __imp__sym2
+ call __imp__sym3
+ call __imp__sym4
+ call __imp__sym5
+ ret
--- /dev/null
+#source: symbols-ordinals-hints-exports.s
+#dlltool: -d ${srcdir}/${subdir}/symbols-ordinals-hints.def -e exports-dlltool.o
+#ld: -shared exports-dlltool.o
+#objdump: -p
+
+# Rules for Ordinal/Name Pointer Table:
+# - Table rows must be lexicographically sorted by symbol names
+# - Hint numbers must be in sequence starting from zero
+# - Ordinal numbers must match the @ordinal keyword from .def file
+# - Symbols in .def file without @ordinal keyword have assigned the first free ordinal starting from 1
+# - Symbols in .def file with NONAME keyword must not be present in Name Pointer Table
+
+#...
+.*\[Ordinal/Name Pointer\] Table -- Ordinal Base.*
+.* Ordinal Hint Name
+.*\+base\[ 2\] 0000 sym1
+.*\+base\[ 5\] 0001 sym2
+.*\+base\[ 3\] 0002 sym4
+.*\+base\[ 4\] 0003 sym5
+
+#pass
--- /dev/null
+#source: symbols-ordinals-hints-exports.s
+#ld: -shared ${srcdir}/${subdir}/symbols-ordinals-hints.def
+#objdump: -p
+
+# Rules for Ordinal/Name Pointer Table:
+# - Table rows must be lexicographically sorted by symbol names
+# - Hint numbers must be in sequence starting from zero
+# - Ordinal numbers must match the @ordinal keyword from .def file
+# - Symbols in .def file without @ordinal keyword have assigned the first free ordinal starting from 1
+# - Symbols in .def file with NONAME keyword must not be present in Name Pointer Table
+
+#...
+.*\[Ordinal/Name Pointer\] Table -- Ordinal Base.*
+.* Ordinal Hint Name
+.*\+base\[ 2\] 0000 sym1
+.*\+base\[ 5\] 0001 sym2
+.*\+base\[ 3\] 0002 sym4
+.*\+base\[ 4\] 0003 sym5
+
+#pass
--- /dev/null
+# define symbols in no specific order
+.global _sym2
+.global _sym5
+.global _sym3
+.global _sym1
+.global _sym4
+_sym2:
+_sym5:
+_sym3:
+_sym1:
+_sym4:
+ ret
--- /dev/null
+#source: symbols-ordinals-hints-call-imports.s
+#dlltool: -d ${srcdir}/${subdir}/symbols-ordinals-hints.def -l libimports-dlltool.a
+#ld: -shared
+#ld_after_inputfiles: libimports-dlltool.a
+#objdump: -p
+
+# Rules for Import Tables:
+# - Ordinal, Hint and Member-Name (what is present) match Ordinal/Name Pointer Table of
+# the external DLL (from corresponding symbols-ordinals-hints-exports-*.d test)
+# - Symbols in .def file with NONAME keyword have only Ordinal, must no have Hint and Member-Name
+# - Symbols in .def file without NONAME keyword have Hint and Member-Name, must not have Ordinal
+
+#...
+The Import Tables \(interpreted \.idata section contents\)
+ vma: Hint Time Forward DLL First
+ Table Stamp Chain Name Thunk
+.*
+
+.*DLL Name:.*
+.* Ordinal Hint Member-Name Bound-To
+.* <none> 0000 sym1
+.* <none> 0001 sym2
+.* 1 <none> <none>
+.* <none> 0002 sym4
+.* <none> 0003 sym5
+
+#pass
--- /dev/null
+#source: symbols-ordinals-hints-exports.s
+#ld: -shared ${srcdir}/${subdir}/symbols-ordinals-hints.def --out-implib libimports-ld.a
+#ld_after_inputfiles: && $AS ${srcdir}/${subdir}/symbols-ordinals-hints-call-imports.s -o call-imports-ld.o && $LD -shared call-imports-ld.o libimports-ld.a -o tmpdir/dump
+#objdump: -p
+
+# Rules for Import Tables:
+# - Ordinal, Hint and Member-Name (what is present) match Ordinal/Name Pointer Table of
+# the external DLL (from corresponding symbols-ordinals-hints-exports-*.d test)
+# - Symbols in .def file with NONAME keyword have only Ordinal, must no have Hint and Member-Name
+# - Symbols in .def file without NONAME keyword have Hint and Member-Name, must not have Ordinal
+
+#...
+The Import Tables \(interpreted \.idata section contents\)
+ vma: Hint Time Forward DLL First
+ Table Stamp Chain Name Thunk
+.*
+
+.*DLL Name:.*
+.* Ordinal Hint Member-Name Bound-To
+.* <none> 0000 sym1
+.* <none> 0001 sym2
+.* 1 <none> <none>
+.* <none> 0002 sym4
+.* <none> 0003 sym5
+
+#pass
--- /dev/null
+LIBRARY "symbols-ordinals-hints.dll"
+EXPORTS
+; define symbols in no specific order
+; define ordinals also in no specific order
+sym2 @5
+sym5
+sym3 @1 NONAME
+sym1 @2
+sym4