From 28a083633c23d5ac0703aa9e98f49a97ffe12652 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 14 Sep 2022 13:07:27 +0200 Subject: [PATCH] cgo: allow --export= in LDFLAGS This allows people to export some functions, such as malloc. Example: // #cgo LDFLAGS: --export=malloc import "C" This exports the function malloc. Note that this is somewhat unsafe right now, but it is used regardless. By using this workaround, people have some time to transition away from using malloc/free directly or until malloc is made safe to be used in this way. --- cgo/security.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cgo/security.go b/cgo/security.go index 2fea40c8a..28bd23ef6 100644 --- a/cgo/security.go +++ b/cgo/security.go @@ -142,6 +142,7 @@ var validLinkerFlags = []*regexp.Regexp{ re(`-L([^@\-].*)`), re(`-O`), re(`-O([^@\-].*)`), + re(`--export=(.+)`), // for wasm-ld re(`-f(no-)?(pic|PIC|pie|PIE)`), re(`-f(no-)?openmp(-simd)?`), re(`-fsanitize=([^@\-].*)`),