patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] drivers: fix symbol exports when map is omitted
@ 2022-11-29 14:00 David Marchand
  2022-11-29 18:23 ` Ferruh Yigit
                   ` (3 more replies)
  0 siblings, 4 replies; 29+ messages in thread
From: David Marchand @ 2022-11-29 14:00 UTC (permalink / raw)
  To: dev
  Cc: ferruh.yigit, stable, Luca Boccassi, Bruce Richardson,
	Abdullah Ömer Yamaç

ld exports any global symbol by default if no version script is passed.
As a consequence, the incriminated change let any public symbol leak
out of the driver shared libraries.

Hide again those symbols by providing a default map file which
unexports any global symbol using a local: * catchall statement.

The check on symbols is skipped for this default map file as it is
intentionnally an empty map (see commit b67bdda86cd4 ("devtools: catch
empty symbol maps")) and there is nothing to check in it.

While at it, move Windows specific objects where needed for better
readability.

Fixes: 7dde9c844a37 ("drivers: omit symbol map when unneeded")
Cc: stable@dpdk.org

Reported-by: Luca Boccassi <luca.boccassi@microsoft.com> 
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/meson.build | 70 ++++++++++++++++++++++++---------------------
 drivers/version.map |  3 ++
 2 files changed, 41 insertions(+), 32 deletions(-)
 create mode 100644 drivers/version.map

diff --git a/drivers/meson.build b/drivers/meson.build
index c4ff3ff1ba..77e92c3bce 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -206,44 +206,50 @@ foreach subpath:subdirs
 
         # now build the shared driver
         version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), drv_path)
-        implib = 'lib' + lib_name + '.dll.a'
 
         lk_deps = []
         lk_args = []
-        if fs.is_file(version_map)
-            def_file = custom_target(lib_name + '_def',
-                    command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-                    input: version_map,
-                    output: '@0@_exports.def'.format(lib_name))
-
-            mingw_map = custom_target(lib_name + '_mingw',
-                    command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-                    input: version_map,
-                    output: '@0@_mingw.map'.format(lib_name))
-
-            lk_deps = [version_map, def_file, mingw_map]
-            if is_windows
-                if is_ms_linker
-                    lk_args = ['-Wl,/def:' + def_file.full_path()]
-                    if meson.version().version_compare('<0.54.0')
-                        lk_args += ['-Wl,/implib:drivers\\' + implib]
-                    endif
-                else
-                    lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
+        if not fs.is_file(version_map)
+            version_map = '@0@/version.map'.format(meson.current_source_dir())
+            lk_deps += [version_map]
+        else
+            lk_deps += [version_map]
+            if not is_windows and developer_mode
+                # on unix systems check the output of the
+                # check-symbols.sh script, using it as a
+                # dependency of the .so build
+                lk_deps += custom_target(lib_name + '.sym_chk',
+                        command: [check_symbols, version_map, '@INPUT@'],
+                        capture: true,
+                        input: static_lib,
+                        output: lib_name + '.sym_chk')
+            endif
+        endif
+
+        if is_windows
+            if is_ms_linker
+                def_file = custom_target(lib_name + '_def',
+                        command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+                        input: version_map,
+                        output: '@0@_exports.def'.format(lib_name))
+                lk_deps += def_file
+
+                lk_args = ['-Wl,/def:' + def_file.full_path()]
+                if meson.version().version_compare('<0.54.0')
+                    implib = 'lib' + lib_name + '.dll.a'
+                    lk_args += ['-Wl,/implib:drivers\\' + implib]
                 endif
             else
-                lk_args = ['-Wl,--version-script=' + version_map]
-                if developer_mode
-                    # on unix systems check the output of the
-                    # check-symbols.sh script, using it as a
-                    # dependency of the .so build
-                    lk_deps += custom_target(lib_name + '.sym_chk',
-                            command: [check_symbols, version_map, '@INPUT@'],
-                            capture: true,
-                            input: static_lib,
-                            output: lib_name + '.sym_chk')
-                endif
+                mingw_map = custom_target(lib_name + '_mingw',
+                        command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+                        input: version_map,
+                        output: '@0@_mingw.map'.format(lib_name))
+                lk_deps += [mingw_map]
+
+                lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
             endif
+        else
+            lk_args = ['-Wl,--version-script=' + version_map]
         endif
 
         shared_lib = shared_library(lib_name, sources,
diff --git a/drivers/version.map b/drivers/version.map
new file mode 100644
index 0000000000..78c3585d7c
--- /dev/null
+++ b/drivers/version.map
@@ -0,0 +1,3 @@
+DPDK_23 {
+	local: *;
+};
-- 
2.38.1


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2022-12-08 16:07 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 14:00 [PATCH] drivers: fix symbol exports when map is omitted David Marchand
2022-11-29 18:23 ` Ferruh Yigit
2022-11-30  7:13   ` David Marchand
2022-11-30  8:27     ` David Marchand
2022-11-30  9:19       ` Ferruh Yigit
2022-12-02  0:11   ` Tyler Retzlaff
2022-11-30 10:02 ` [PATCH v2] " David Marchand
2022-11-30 10:44   ` Ferruh Yigit
2022-11-30 15:02     ` David Marchand
2022-11-30 15:24       ` David Marchand
2022-11-30 15:42       ` Bruce Richardson
2022-12-01 10:11         ` David Marchand
2022-12-01 10:08 ` [PATCH v3 1/2] " David Marchand
2022-12-01 10:55   ` Bruce Richardson
2022-12-02 10:01     ` David Marchand
2022-12-02 11:09 ` [PATCH v4 " David Marchand
2022-12-02 13:39   ` Aaron Conole
2022-12-05 10:23     ` David Marchand
2022-12-05 10:43       ` [EXT] " Akhil Goyal
2022-12-05 12:36         ` David Marchand
2022-12-05 13:47           ` Akhil Goyal
2022-12-05 15:37             ` Thomas Monjalon
2022-12-05 16:26               ` Akhil Goyal
2022-12-06 10:12               ` Ferruh Yigit
2022-12-06 10:18                 ` David Marchand
2022-12-06 12:25                   ` Ferruh Yigit
2022-12-07 18:00                     ` Patrick Robb
2022-12-08 13:22                       ` Thomas Monjalon
2022-12-08 16:06                         ` Patrick Robb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).