“go build-buildmode=c-shared”编译的dll,如何隐藏导出的goruntime函数?

“go build-buildmode=c-shared”编译的dll,如何隐藏导出的goruntime函数?,go,Go,使用dumpbin查看导出函数,我发现很多goruntime函数导出,希望能隐藏它们 例如: // file hello.go package main // //Needed for build import "C" import ( "fmt" ) //export SayHello func SayHello(name string) { fmt.Printf("func in Golang SayHello says: Hello, %s!\n", name) }

使用dumpbin查看导出函数,我发现很多goruntime函数导出,希望能隐藏它们

例如:


// file hello.go
package main

// //Needed for build
import "C"

import (
    "fmt"
)

//export SayHello
func SayHello(name string) {
    fmt.Printf("func in Golang SayHello says: Hello, %s!\n", name)
}

//export SayHelloByte
func SayHelloByte(name []byte) {
    fmt.Printf("func in Golang SayHelloByte says: Hello, %s!\n", string(name))
}

//export SayBye
func SayBye() {
    fmt.Println("func in Golang SayBye says: Bye!")
}

func main() {
    // We need the main function to make possible
    // CGO compiler to compile the package as C shared library
}
我只想导出SayHello、SayHelloByte和SayBye函数,而不是导出goruntime函数

我该怎么办?我搜索了几个小时,没有找到找到找到golang的方法

非常感谢。

现在正是针对这个问题提出的。

现在正是针对这个问题提出的

>go build -buildmode=c-shared -o libhello.dll hello.go
>dumpbin -exports libhello.dll
Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file libhello.dll

File Type: DLL

  Section contains the following exports for libhello.dll

    00000000 characteristics
    5C7FB64A time date stamp Wed Mar  6 20:00:10 2019
        0.00 version
           1 ordinal base
        3320 number of functions
        3320 number of names

    ordinal hint RVA      name

          1    0 00092F50 SayBye
          2    1 00092EA0 SayHello
          3    2 00092EF0 SayHelloByte
          4    3 00093240 _cgo_get_context_function
          5    4 000A1A68 _cgo_init
          6    5 000930E0 _cgo_is_runtime_initialized
          7    6 00093020 _cgo_maybe_run_preinit
          8    7 000A1A70 _cgo_notify_runtime_init_done
          9    8 00058970 _cgo_panic
         10    9 00092FC0 _cgo_preinit_init
         11    A 00092F90 _cgo_release_context
         12    B 000A1A78 _cgo_sys_thread_create
         13    C 00093330 _cgo_sys_thread_start
         14    D 000A1A80 _cgo_thread_start
         15    E 00052090 _cgo_topofstack
         16    F 00093110 _cgo_wait_runtime_init_done
         17   10 0016E070 _cgo_yield
         18   11 00092D20 _cgoexp_fd8bec644a00_SayBye
         19   12 00092AA0 _cgoexp_fd8bec644a00_SayHello
         20   13 00092BD0 _cgoexp_fd8bec644a00_SayHelloByte
         21   14 000538A0 _rt0_amd64_windows_lib
         22   15 000A1A40 _rt0_amd64_windows_lib.ptr
         23   16 00053900 _rt0_amd64_windows_lib_go
         24   17 000589C0 crosscall2
         25   18 00093380 crosscall_amd64
         26   19 0005B450 errors.(*errorString).Error
         27   1A 0005B3C0 errors.New
         28   1B 0008A230 fmt.(*buffer).WriteRune
         29   1C 000884A0 fmt.(*fmt).fmtBoolean
         30   1D 00089030 fmt.(*fmt).fmtBs
         31   1E 00089870 fmt.(*fmt).fmtC
         32   1F 00089A40 fmt.(*fmt).fmtFloat
         33   20 000888B0 fmt.(*fmt).fmtInteger
         34   21 00089660 fmt.(*fmt).fmtQ
         35   22 00089930 fmt.(*fmt).fmtQc
         36   23 00088FB0 fmt.(*fmt).fmtS
         37   24 000890C0 fmt.(*fmt).fmtSbx
         38   25 00088530 fmt.(*fmt).fmtUnicode
         39   26 00087DF0 fmt.(*fmt).pad
         40   27 00088150 fmt.(*fmt).padString
         41   28 00088E70 fmt.(*fmt).truncate
         42   29 00088D80 fmt.(*fmt).truncateString
         43   2A 00087C60 fmt.(*fmt).writePadding
         44   2B 0008A620 fmt.(*pp).Flag
         45   2C 0008A600 fmt.(*pp).Precision
         46   2D 0008A5E0 fmt.(*pp).Width
         47   2E 0008A6B0 fmt.(*pp).Write
         48   2F 00091000 fmt.(*pp).argNumber
         49   30 00091120 fmt.(*pp).badArgNum
         50   31 0008AEF0 fmt.(*pp).badVerb
         51   32 0008CDB0 fmt.(*pp).catchPanic
         52   33 00091440 fmt.(*pp).doPrintf
         53   34 000925A0 fmt.(*pp).doPrintln

...