merge 46805 from amd64 branch:
[reactos.git] / reactos / tools / rbuild / backend / mingw / linkers / ld.mak
index dbba33e..d7fc3b7 100644 (file)
@@ -1,10 +1,17 @@
-LDFLAG_DLL:=-shared
-LDFLAG_DRIVER:=-shared --subsystem=native
-LDFLAG_NOSTDLIB:=-nostartfiles -nostdlib
+# -exclude-all-symbols disables autoexporting all symbols *if none were found* (either in a DEF file or using __declspec(dllexport)
+LDFLAG_DLL:=--shared --exclude-all-symbols
+LDFLAG_DRIVER:=--shared --subsystem=native --exclude-all-symbols
+LDFLAG_NOSTDLIB:=--nostartfiles --nostdlib
 LDFLAG_CONSOLE:=--subsystem=console
 LDFLAG_WINDOWS:=--subsystem=windows
 LDFLAG_NATIVE:=--subsystem=native
 
+LDFLAG_EXCLUDE_ALL_SYMBOLS=--exclude-all-symbols
+DLLTOOL_FLAGS=--kill-at
+ifeq ($(ARCH),amd64)
+    DLLTOOL_FLAGS= --no-leading-underscore
+endif
+
 #~ #(module, objs, deps, ldflags, output, def, libs, entry, base)
 #(module, objs, deps, ldflags, output, def, libs, entry, base, extralibs)
 define RBUILD_LINK
@@ -12,15 +19,15 @@ define RBUILD_LINK
 ifneq ($(6),)
 ${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib${call RBUILD_name,$(5)}.a: $(6) | ${call RBUILD_intermediate_path,$(5)}
        $$(ECHO_IMPLIB)
-       $${dlltool} --def $(6) --kill-at --output-lib=$$@
+       $${dlltool} --def $(6) $(DLLTOOL_FLAGS) --output-lib=$$@
 
 ${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib${call RBUILD_name,$(5)}.delayimp.a: $(6) | ${call RBUILD_intermediate_path,$(5)}
        $$(ECHO_IMPLIB)
-       $${dlltool} --def $(6) --kill-at --output-delaylib=$$@
+       $${dlltool} --def $(6) $(DLLTOOL_FLAGS) --output-delaylib=$$@
 
 ${call RBUILD_intermediate_path_noext,$(5)}.exp: $(6) | ${call RBUILD_intermediate_path,$(5)}
        $$(ECHO_IMPLIB)
-       $${dlltool} --def $(6) --kill-at --output-exp=$$@
+       $${dlltool} --def $(6) $(DLLTOOL_FLAGS) --output-exp=$$@
 
 $(1)_CLEANFILES+=\
        ${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib$(notdir $(5)).a \
@@ -40,7 +47,7 @@ $(1)_CLEANFILES+=${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp
 $(5): ${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp $(7) $(3) $$(RSYM_TARGET) $$(PEFIXUP_TARGET) | ${call RBUILD_dir,$(5)}
        $$(ECHO_LD)
 #~     $${ld} --entry=$(8) --image-base=$(9) @${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp $(7) ${call RBUILD_ldflags,$(1),$(4)} -o $$@
-       $${ld} --entry=$(8) --image-base=$(9) @${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp $(10) $(7) $(10) ${call RBUILD_ldflags,$(1),$(4)} -o $$@
+       $${ld} --entry=$(8) --image-base=$(9) @${call RBUILD_intermediate_dir,$(5)}$$(SEP)$(1)_objs.rsp --start-group $(10) $(7) --end-group ${call RBUILD_ldflags,$(1),$(4)} -o $$@
 ifneq ($(or $(6),$$(MODULETYPE$$($(1)_TYPE)_KMODE)),)
        $$(ECHO_PEFIXUP)
        $$(Q)$$(PEFIXUP_TARGET) $$@ $(if $(6),-exports) $$(if $$(MODULETYPE$($(1)_TYPE)_KMODE),-sections)