Skip to content

Commit b537a6f

Browse files
committed
Hide all driver private symbols from runtime library
Use GCC visibility pragma to hide all driver private symbols which should not be exported to other runtime libraries. This GCC visibility pragma is supported since GCC 4.1.0. All non-static functions and variables in C sources of DBD::MariaDB would not be visible or exported to other runtime libraries. This fixes problem when two or more DBI drivers (probably DBD::mysql) export same function symbol as DBD::MariaDB. It could cause unexpected behavior when more DBI drivers are used by Perl applications as correct function symbol for driver does not have to be loaded.
1 parent e810631 commit b537a6f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

dbdimp.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515

1616
#include "dbdimp.h"
1717

18+
#ifdef HAVE_GET_CHARSET_NUMBER
19+
/* Available only in some clients and declared in header file my_sys.h which cannot be included */
20+
unsigned int get_charset_number(const char *cs_name, unsigned int cs_flags);
21+
#endif
22+
23+
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
24+
/* Do not export non-static functions from driver library */
25+
#pragma GCC visibility push(hidden)
26+
#endif
27+
1828
#define ASYNC_CHECK_RETURN(h, value)\
1929
if(imp_dbh->async_query_in_flight) {\
2030
mariadb_dr_do_error(h, CR_UNKNOWN_ERROR, "Calling a synchronous function on an asynchronous handle", "HY000");\
@@ -1364,11 +1374,6 @@ static void error_no_connection(SV *h, const char *msg)
13641374
mariadb_dr_do_error(h, CR_CONNECTION_ERROR, msg, "HY000");
13651375
}
13661376

1367-
#ifdef HAVE_GET_CHARSET_NUMBER
1368-
/* Available only in some clients and declared in header file my_sys.h which cannot be included */
1369-
unsigned int get_charset_number(const char *cs_name, unsigned int cs_flags);
1370-
#endif
1371-
13721377
/***************************************************************************
13731378
*
13741379
* Name: mariadb_dr_connect

socket.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
#include <unistd.h>
1717
#endif
1818

19+
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4))
20+
/* Do not export non-static functions from driver library */
21+
#pragma GCC visibility push(hidden)
22+
#endif
23+
1924
/*
2025
* Warning: Native socket code must be outside of dbdimp.c and dbdimp.h because
2126
* perl header files redefine socket function. This file must not

0 commit comments

Comments
 (0)