All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
@ 2015-10-29 19:07 Mike Frysinger
  2015-11-01 22:09 ` Jan Engelhardt
  2015-11-14  0:45 ` Neutron Soutmun
  0 siblings, 2 replies; 8+ messages in thread
From: Mike Frysinger @ 2015-10-29 19:07 UTC (permalink / raw)
  To: netfilter-devel; +Cc: neo.neutron

[-- Attachment #1: Type: text/plain, Size: 33542 bytes --]

Neutron Soutmun wrote:
> * libmnl using an export map (-Wl,--version-script=),
>  hence, no need to explicitly use the EXPORT_SYMBOL() tags.

this isn't entirely accurate.  the use of hidden visibility allows for
optimizations (e.g. bypassing the PLT).  export maps merely control the
final visibility of the symbols at link time ... gcc is forced to assume
every function call otherwise is still globally visible (exported).

it doesn't make a big difference in the libmnl case as there aren't any
real internal-only symbols, but in larger libraries, this sort of change
increases code size and runtime overhead.

this is why libraries take a different approach: set default visibility
to hidden and then update the header with a macro like EXPORT.  there is
only one file to declare the prototypes and the visibility markings are
right there.  no need for EXPORT_SYMBOL() lines.  the export map is only
really for toolchains that lack visibility support.

something as simple as the patch below
-mike

diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 5adb13c..787882e 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -12,6 +12,10 @@
 extern "C" {
 #endif
 
+#ifndef MNL_EXPORT
+# define MNL_EXPORT extern
+#endif
+
 /*
  * Netlink socket API
  */
@@ -21,17 +25,17 @@ extern "C" {
 
 struct mnl_socket;
 
-extern struct mnl_socket *mnl_socket_open(int bus);
-extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
-extern struct mnl_socket *mnl_socket_fdopen(int fd);
-extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
-extern int mnl_socket_close(struct mnl_socket *nl);
-extern int mnl_socket_get_fd(const struct mnl_socket *nl);
-extern unsigned int mnl_socket_get_portid(const struct mnl_socket *nl);
-extern ssize_t mnl_socket_sendto(const struct mnl_socket *nl, const void *req, size_t siz);
-extern ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t siz);
-extern int mnl_socket_setsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t len);
-extern int mnl_socket_getsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t *len);
+MNL_EXPORT struct mnl_socket *mnl_socket_open(int bus);
+MNL_EXPORT struct mnl_socket *mnl_socket_open2(int bus, int flags);
+MNL_EXPORT struct mnl_socket *mnl_socket_fdopen(int fd);
+MNL_EXPORT int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid);
+MNL_EXPORT int mnl_socket_close(struct mnl_socket *nl);
+MNL_EXPORT int mnl_socket_get_fd(const struct mnl_socket *nl);
+MNL_EXPORT unsigned int mnl_socket_get_portid(const struct mnl_socket *nl);
+MNL_EXPORT ssize_t mnl_socket_sendto(const struct mnl_socket *nl, const void *req, size_t siz);
+MNL_EXPORT ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t siz);
+MNL_EXPORT int mnl_socket_setsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t len);
+MNL_EXPORT int mnl_socket_getsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t *len);
 
 /*
  * Netlink message API
@@ -41,41 +45,41 @@ extern int mnl_socket_getsockopt(const struct mnl_socket *nl, int type, void *bu
 #define MNL_ALIGN(len)		(((len)+MNL_ALIGNTO-1) & ~(MNL_ALIGNTO-1))
 #define MNL_NLMSG_HDRLEN	MNL_ALIGN(sizeof(struct nlmsghdr))
 
-extern size_t mnl_nlmsg_size(size_t len);
-extern size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh);
+MNL_EXPORT size_t mnl_nlmsg_size(size_t len);
+MNL_EXPORT size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh);
 
 /* Netlink message header builder */
-extern struct nlmsghdr *mnl_nlmsg_put_header(void *buf);
-extern void *mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size);
+MNL_EXPORT struct nlmsghdr *mnl_nlmsg_put_header(void *buf);
+MNL_EXPORT void *mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size);
 
 /* Netlink message iterators */
-extern bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len);
-extern struct nlmsghdr *mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len);
+MNL_EXPORT bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len);
+MNL_EXPORT struct nlmsghdr *mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len);
 
 /* Netlink sequence tracking */
-extern bool mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq);
+MNL_EXPORT bool mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq);
 
 /* Netlink portID checking */
-extern bool mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, unsigned int portid);
+MNL_EXPORT bool mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, unsigned int portid);
 
 /* Netlink message getters */
-extern void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh);
-extern void *mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset);
-extern void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh);
+MNL_EXPORT void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh);
+MNL_EXPORT void *mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset);
+MNL_EXPORT void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh);
 
 /* Netlink message printer */
-extern void mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen, size_t extra_header_size);
+MNL_EXPORT void mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen, size_t extra_header_size);
 
 /* Message batch helpers */
 struct mnl_nlmsg_batch;
-extern struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, size_t bufsiz);
-extern bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b);
-extern void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b);
-extern size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b);
-extern void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b);
-extern void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b);
-extern void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b);
-extern bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b);
+MNL_EXPORT struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, size_t bufsiz);
+MNL_EXPORT bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b);
+MNL_EXPORT void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b);
+MNL_EXPORT size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b);
+MNL_EXPORT void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b);
+MNL_EXPORT void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b);
+MNL_EXPORT void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b);
+MNL_EXPORT bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b);
 
 /*
  * Netlink attributes API
@@ -83,42 +87,42 @@ extern bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b);
 #define MNL_ATTR_HDRLEN	MNL_ALIGN(sizeof(struct nlattr))
 
 /* TLV attribute getters */
-extern uint16_t mnl_attr_get_type(const struct nlattr *attr);
-extern uint16_t mnl_attr_get_len(const struct nlattr *attr);
-extern uint16_t mnl_attr_get_payload_len(const struct nlattr *attr);
-extern void *mnl_attr_get_payload(const struct nlattr *attr);
-extern uint8_t mnl_attr_get_u8(const struct nlattr *attr);
-extern uint16_t mnl_attr_get_u16(const struct nlattr *attr);
-extern uint32_t mnl_attr_get_u32(const struct nlattr *attr);
-extern uint64_t mnl_attr_get_u64(const struct nlattr *attr);
-extern const char *mnl_attr_get_str(const struct nlattr *attr);
+MNL_EXPORT uint16_t mnl_attr_get_type(const struct nlattr *attr);
+MNL_EXPORT uint16_t mnl_attr_get_len(const struct nlattr *attr);
+MNL_EXPORT uint16_t mnl_attr_get_payload_len(const struct nlattr *attr);
+MNL_EXPORT void *mnl_attr_get_payload(const struct nlattr *attr);
+MNL_EXPORT uint8_t mnl_attr_get_u8(const struct nlattr *attr);
+MNL_EXPORT uint16_t mnl_attr_get_u16(const struct nlattr *attr);
+MNL_EXPORT uint32_t mnl_attr_get_u32(const struct nlattr *attr);
+MNL_EXPORT uint64_t mnl_attr_get_u64(const struct nlattr *attr);
+MNL_EXPORT const char *mnl_attr_get_str(const struct nlattr *attr);
 
 /* TLV attribute putters */
-extern void mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data);
-extern void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data);
-extern void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data);
-extern void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data);
-extern void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data);
-extern void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data);
-extern void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data);
+MNL_EXPORT void mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data);
+MNL_EXPORT void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data);
+MNL_EXPORT void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data);
+MNL_EXPORT void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data);
+MNL_EXPORT void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data);
+MNL_EXPORT void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data);
+MNL_EXPORT void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data);
 
 /* TLV attribute putters with buffer boundary checkings */
-extern bool mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, size_t len, const void *data);
-extern bool mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint8_t data);
-extern bool mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint16_t data);
-extern bool mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint32_t data);
-extern bool mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint64_t data);
-extern bool mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data);
-extern bool mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data);
+MNL_EXPORT bool mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, size_t len, const void *data);
+MNL_EXPORT bool mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint8_t data);
+MNL_EXPORT bool mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint16_t data);
+MNL_EXPORT bool mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint32_t data);
+MNL_EXPORT bool mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint64_t data);
+MNL_EXPORT bool mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data);
+MNL_EXPORT bool mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data);
 
 /* TLV attribute nesting */
-extern struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type);
-extern struct nlattr *mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type);
-extern void mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start);
-extern void mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start);
+MNL_EXPORT struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type);
+MNL_EXPORT struct nlattr *mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type);
+MNL_EXPORT void mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start);
+MNL_EXPORT void mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start);
 
 /* TLV validation */
-extern int mnl_attr_type_valid(const struct nlattr *attr, uint16_t maxtype);
+MNL_EXPORT int mnl_attr_type_valid(const struct nlattr *attr, uint16_t maxtype);
 
 enum mnl_attr_data_type {
 	MNL_TYPE_UNSPEC,
@@ -136,12 +140,12 @@ enum mnl_attr_data_type {
 	MNL_TYPE_MAX,
 };
 
-extern int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type);
-extern int mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type, size_t len);
+MNL_EXPORT int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type);
+MNL_EXPORT int mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type, size_t len);
 
 /* TLV iterators */
-extern bool mnl_attr_ok(const struct nlattr *attr, int len);
-extern struct nlattr *mnl_attr_next(const struct nlattr *attr);
+MNL_EXPORT bool mnl_attr_ok(const struct nlattr *attr, int len);
+MNL_EXPORT struct nlattr *mnl_attr_next(const struct nlattr *attr);
 
 #define mnl_attr_for_each(attr, nlh, offset) \
 	for ((attr) = mnl_nlmsg_get_payload_offset((nlh), (offset)); \
@@ -161,9 +165,9 @@ extern struct nlattr *mnl_attr_next(const struct nlattr *attr);
 /* TLV callback-based attribute parsers */
 typedef int (*mnl_attr_cb_t)(const struct nlattr *attr, void *data);
 
-extern int mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset, mnl_attr_cb_t cb, void *data);
-extern int mnl_attr_parse_nested(const struct nlattr *attr, mnl_attr_cb_t cb, void *data);
-extern int mnl_attr_parse_payload(const void *payload, size_t payload_len, mnl_attr_cb_t cb, void *data);
+MNL_EXPORT int mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset, mnl_attr_cb_t cb, void *data);
+MNL_EXPORT int mnl_attr_parse_nested(const struct nlattr *attr, mnl_attr_cb_t cb, void *data);
+MNL_EXPORT int mnl_attr_parse_payload(const void *payload, size_t payload_len, mnl_attr_cb_t cb, void *data);
 
 /*
  * callback API
@@ -174,10 +178,10 @@ extern int mnl_attr_parse_payload(const void *payload, size_t payload_len, mnl_a
 
 typedef int (*mnl_cb_t)(const struct nlmsghdr *nlh, void *data);
 
-extern int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq,
+MNL_EXPORT int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq,
 		      unsigned int portid, mnl_cb_t cb_data, void *data);
 
-extern int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
+MNL_EXPORT int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
 		       unsigned int portid, mnl_cb_t cb_data, void *data,
 		       mnl_cb_t *cb_ctl_array, unsigned int cb_ctl_array_len);
 
@@ -194,7 +198,7 @@ extern int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
 #endif
 
 #ifdef __cplusplus
-} /* extern "C" */
+} /* MNL_EXPORT "C" */
 #endif
 
 #endif
diff --git a/src/attr.c b/src/attr.c
index c551d0b..55b0f8c 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -6,11 +6,11 @@
  * by the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  */
+#include "internal.h"
 #include <limits.h>	/* for INT_MAX */
 #include <libmnl/libmnl.h>
 #include <string.h>
 #include <errno.h>
-#include "internal.h"
 
 /**
  * \defgroup attr Netlink attribute helpers
@@ -39,7 +39,6 @@ uint16_t mnl_attr_get_type(const struct nlattr *attr)
 {
 	return attr->nla_type & NLA_TYPE_MASK;
 }
-EXPORT_SYMBOL(mnl_attr_get_type);
 
 /**
  * mnl_attr_get_len - get length of netlink attribute
@@ -52,7 +51,6 @@ uint16_t mnl_attr_get_len(const struct nlattr *attr)
 {
 	return attr->nla_len;
 }
-EXPORT_SYMBOL(mnl_attr_get_len);
 
 /**
  * mnl_attr_get_payload_len - get the attribute payload-value length
@@ -64,7 +62,6 @@ uint16_t mnl_attr_get_payload_len(const struct nlattr *attr)
 {
 	return attr->nla_len - MNL_ATTR_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_attr_get_payload_len);
 
 /**
  * mnl_attr_get_payload - get pointer to the attribute payload
@@ -76,7 +73,6 @@ void *mnl_attr_get_payload(const struct nlattr *attr)
 {
 	return (void *)attr + MNL_ATTR_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_attr_get_payload);
 
 /**
  * mnl_attr_ok - check if there is room for an attribute in a buffer
@@ -100,7 +96,6 @@ bool mnl_attr_ok(const struct nlattr *attr, int len)
 	       attr->nla_len >= sizeof(struct nlattr) &&
 	       (int)attr->nla_len <= len;
 }
-EXPORT_SYMBOL(mnl_attr_ok);
 
 /**
  * mnl_attr_next - get the next attribute in the payload of a netlink message
@@ -114,7 +109,6 @@ struct nlattr *mnl_attr_next(const struct nlattr *attr)
 {
 	return (struct nlattr *)((void *)attr + MNL_ALIGN(attr->nla_len));
 }
-EXPORT_SYMBOL(mnl_attr_next);
 
 /**
  * mnl_attr_type_valid - check if the attribute type is valid
@@ -138,7 +132,6 @@ int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max)
 	}
 	return 1;
 }
-EXPORT_SYMBOL(mnl_attr_type_valid);
 
 static int __mnl_attr_validate(const struct nlattr *attr,
 			       enum mnl_attr_data_type type, size_t exp_len)
@@ -222,7 +215,6 @@ int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type)
 	exp_len = mnl_attr_data_type_len[type];
 	return __mnl_attr_validate(attr, type, exp_len);
 }
-EXPORT_SYMBOL(mnl_attr_validate);
 
 /**
  * mnl_attr_validate2 - validate netlink attribute (extended version)
@@ -244,7 +236,6 @@ mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type,
 	}
 	return __mnl_attr_validate(attr, type, exp_len);
 }
-EXPORT_SYMBOL(mnl_attr_validate2);
 
 /**
  * mnl_attr_parse - parse attributes
@@ -273,7 +264,6 @@ mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset,
 			return ret;
 	return ret;
 }
-EXPORT_SYMBOL(mnl_attr_parse);
 
 /**
  * mnl_attr_parse_nested - parse attributes inside a nest
@@ -301,7 +291,6 @@ mnl_attr_parse_nested(const struct nlattr *nested, mnl_attr_cb_t cb,
 			return ret;
 	return ret;
 }
-EXPORT_SYMBOL(mnl_attr_parse_nested);
 
 /**
  * mnl_attr_parse_payload - parse attributes in payload of Netlink message
@@ -334,7 +323,6 @@ mnl_attr_parse_payload(const void *payload, size_t payload_len,
 			return ret;
 	return ret;
 }
-EXPORT_SYMBOL(mnl_attr_parse_payload);
 
 /**
  * mnl_attr_get_u8 - returns 8-bit unsigned integer attribute payload
@@ -346,7 +334,6 @@ uint8_t mnl_attr_get_u8(const struct nlattr *attr)
 {
 	return *((uint8_t *)mnl_attr_get_payload(attr));
 }
-EXPORT_SYMBOL(mnl_attr_get_u8);
 
 /**
  * mnl_attr_get_u16 - returns 16-bit unsigned integer attribute payload
@@ -358,7 +345,6 @@ uint16_t mnl_attr_get_u16(const struct nlattr *attr)
 {
 	return *((uint16_t *)mnl_attr_get_payload(attr));
 }
-EXPORT_SYMBOL(mnl_attr_get_u16);
 
 /**
  * mnl_attr_get_u32 - returns 32-bit unsigned integer attribute payload
@@ -370,7 +356,6 @@ uint32_t mnl_attr_get_u32(const struct nlattr *attr)
 {
 	return *((uint32_t *)mnl_attr_get_payload(attr));
 }
-EXPORT_SYMBOL(mnl_attr_get_u32);
 
 /**
  * mnl_attr_get_u64 - returns 64-bit unsigned integer attribute.
@@ -386,7 +371,6 @@ uint64_t mnl_attr_get_u64(const struct nlattr *attr)
 	memcpy(&tmp, mnl_attr_get_payload(attr), sizeof(tmp));
 	return tmp;
 }
-EXPORT_SYMBOL(mnl_attr_get_u64);
 
 /**
  * mnl_attr_get_str - returns pointer to string attribute.
@@ -398,7 +382,6 @@ const char *mnl_attr_get_str(const struct nlattr *attr)
 {
 	return mnl_attr_get_payload(attr);
 }
-EXPORT_SYMBOL(mnl_attr_get_str);
 
 /**
  * mnl_attr_put - add an attribute to netlink message
@@ -421,7 +404,6 @@ mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
 	memcpy(mnl_attr_get_payload(attr), data, len);
 	nlh->nlmsg_len += MNL_ALIGN(payload_len);
 }
-EXPORT_SYMBOL(mnl_attr_put);
 
 /**
  * mnl_attr_put_u8 - add 8-bit unsigned integer attribute to netlink message
@@ -436,7 +418,6 @@ void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint8_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u8);
 
 /**
  * mnl_attr_put_u16 - add 16-bit unsigned integer attribute to netlink message
@@ -451,7 +432,6 @@ void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint16_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u16);
 
 /**
  * mnl_attr_put_u32 - add 32-bit unsigned integer attribute to netlink message
@@ -466,7 +446,6 @@ void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint32_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u32);
 
 /**
  * mnl_attr_put_u64 - add 64-bit unsigned integer attribute to netlink message
@@ -481,7 +460,6 @@ void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint64_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u64);
 
 /**
  * mnl_attr_put_str - add string attribute to netlink message
@@ -496,7 +474,6 @@ void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data)
 {
 	mnl_attr_put(nlh, type, strlen(data), data);
 }
-EXPORT_SYMBOL(mnl_attr_put_str);
 
 /**
  * mnl_attr_put_strz - add string attribute to netlink message
@@ -514,7 +491,6 @@ void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data)
 {
 	mnl_attr_put(nlh, type, strlen(data)+1, data);
 }
-EXPORT_SYMBOL(mnl_attr_put_strz);
 
 /**
  * mnl_attr_nest_start - start an attribute nest
@@ -535,7 +511,6 @@ struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type)
 
 	return start;
 }
-EXPORT_SYMBOL(mnl_attr_nest_start);
 
 /**
  * mnl_attr_put_check - add an attribute to netlink message
@@ -560,7 +535,6 @@ mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen,
 	mnl_attr_put(nlh, type, len, data);
 	return true;
 }
-EXPORT_SYMBOL(mnl_attr_put_check);
 
 /**
  * mnl_attr_put_u8_check - add 8-bit unsigned int attribute to netlink message
@@ -581,7 +555,6 @@ mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint8_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u8_check);
 
 /**
  * mnl_attr_put_u16_check - add 16-bit unsigned int attribute to netlink message
@@ -604,7 +577,6 @@ mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint16_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u16_check);
 
 /**
  * mnl_attr_put_u32_check - add 32-bit unsigned int attribute to netlink message
@@ -627,7 +599,6 @@ mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint32_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u32_check);
 
 /**
  * mnl_attr_put_u64_check - add 64-bit unsigned int attribute to netlink message
@@ -650,7 +621,6 @@ mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint64_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u64_check);
 
 /**
  * mnl_attr_put_str_check - add string attribute to netlink message
@@ -673,7 +643,6 @@ mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, strlen(data), data);
 }
-EXPORT_SYMBOL(mnl_attr_put_str_check);
 
 /**
  * mnl_attr_put_strz_check - add string attribute to netlink message
@@ -697,7 +666,6 @@ mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, strlen(data)+1, data);
 }
-EXPORT_SYMBOL(mnl_attr_put_strz_check);
 
 /**
  * mnl_attr_nest_start_check - start an attribute nest
@@ -716,7 +684,6 @@ mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type)
 		return NULL;
 	return mnl_attr_nest_start(nlh, type);
 }
-EXPORT_SYMBOL(mnl_attr_nest_start_check);
 
 /**
  * mnl_attr_nest_end - end an attribute nest
@@ -730,7 +697,6 @@ mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start)
 {
 	start->nla_len = mnl_nlmsg_get_payload_tail(nlh) - (void *)start;
 }
-EXPORT_SYMBOL(mnl_attr_nest_end);
 
 /**
  * mnl_attr_nest_cancel - cancel an attribute nest
@@ -744,7 +710,6 @@ mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start)
 {
 	nlh->nlmsg_len -= mnl_nlmsg_get_payload_tail(nlh) - (void *)start;
 }
-EXPORT_SYMBOL(mnl_attr_nest_cancel);
 
 /**
  * @}
diff --git a/src/callback.c b/src/callback.c
index f023401..a7a1791 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -7,9 +7,9 @@
  * (at your option) any later version.
  */
 
+#include "internal.h"
 #include <errno.h>
 #include <libmnl/libmnl.h>
-#include "internal.h"
 
 static int mnl_cb_noop(const struct nlmsghdr *nlh, void *data)
 {
@@ -134,7 +134,6 @@ mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
 	return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data,
 			    cb_ctl_array, cb_ctl_array_len);
 }
-EXPORT_SYMBOL(mnl_cb_run2);
 
 /**
  * mnl_cb_run - callback runqueue for netlink messages (simplified version)
@@ -161,7 +160,6 @@ mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq,
 {
 	return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data, NULL, 0);
 }
-EXPORT_SYMBOL(mnl_cb_run);
 
 /**
  * @}
diff --git a/src/internal.h b/src/internal.h
index 3a88d1a..7592c09 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -3,10 +3,7 @@
 
 #include "config.h"
 #ifdef HAVE_VISIBILITY_HIDDEN
-#	define __visible	__attribute__((visibility("default")))
-#	define EXPORT_SYMBOL(x)	typeof(x) (x) __visible
-#else
-#	define EXPORT_SYMBOL
+#	define MNL_EXPORT extern __attribute__((visibility("default")))
 #endif
 
 #endif
diff --git a/src/nlmsg.c b/src/nlmsg.c
index fd2f698..9c6b223 100644
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -6,6 +6,7 @@
  * by the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  */
+#include "internal.h"
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -13,7 +14,6 @@
 #include <errno.h>
 #include <string.h>
 #include <libmnl/libmnl.h>
-#include "internal.h"
 
 /**
  * \defgroup nlmsg Netlink message helpers
@@ -55,7 +55,6 @@ size_t mnl_nlmsg_size(size_t len)
 {
 	return len + MNL_NLMSG_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_nlmsg_size);
 
 /**
  * mnl_nlmsg_get_payload_len - get the length of the Netlink payload
@@ -68,7 +67,6 @@ size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh)
 {
 	return nlh->nlmsg_len - MNL_NLMSG_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload_len);
 
 /**
  * mnl_nlmsg_put_header - reserve and prepare room for Netlink header
@@ -88,7 +86,6 @@ struct nlmsghdr *mnl_nlmsg_put_header(void *buf)
 	nlh->nlmsg_len = len;
 	return nlh;
 }
-EXPORT_SYMBOL(mnl_nlmsg_put_header);
 
 /**
  * mnl_nlmsg_put_extra_header - reserve and prepare room for an extra header
@@ -110,7 +107,6 @@ mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size)
 	memset(ptr, 0, len);
 	return ptr;
 }
-EXPORT_SYMBOL(mnl_nlmsg_put_extra_header);
 
 /**
  * mnl_nlmsg_get_payload - get a pointer to the payload of the netlink message
@@ -122,7 +118,6 @@ void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh)
 {
 	return (void *)nlh + MNL_NLMSG_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload);
 
 /**
  * mnl_nlmsg_get_payload_offset - get a pointer to the payload of the message
@@ -137,7 +132,6 @@ mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset)
 {
 	return (void *)nlh + MNL_NLMSG_HDRLEN + MNL_ALIGN(offset);
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload_offset);
 
 /**
  * mnl_nlmsg_ok - check a there is room for netlink message
@@ -161,7 +155,6 @@ bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len)
 	       nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
 	       (int)nlh->nlmsg_len <= len;
 }
-EXPORT_SYMBOL(mnl_nlmsg_ok);
 
 /**
  * mnl_nlmsg_next - get the next netlink message in a multipart message
@@ -182,7 +175,6 @@ mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len)
 	*len -= MNL_ALIGN(nlh->nlmsg_len);
 	return (struct nlmsghdr *)((void *)nlh + MNL_ALIGN(nlh->nlmsg_len));
 }
-EXPORT_SYMBOL(mnl_nlmsg_next);
 
 /**
  * mnl_nlmsg_get_payload_tail - get the ending of the netlink message
@@ -196,7 +188,6 @@ void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh)
 {
 	return (void *)nlh + MNL_ALIGN(nlh->nlmsg_len);
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload_tail);
 
 /**
  * mnl_nlmsg_seq_ok - perform sequence tracking
@@ -217,7 +208,6 @@ mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq)
 {
 	return nlh->nlmsg_seq && seq ? nlh->nlmsg_seq == seq : true;
 }
-EXPORT_SYMBOL(mnl_nlmsg_seq_ok);
 
 /**
  * mnl_nlmsg_portid_ok - perform portID origin check
@@ -238,7 +228,6 @@ mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, unsigned int portid)
 {
 	return nlh->nlmsg_pid && portid ? nlh->nlmsg_pid == portid : true;
 }
-EXPORT_SYMBOL(mnl_nlmsg_portid_ok);
 
 static void mnl_nlmsg_fprintf_header(FILE *fd, const struct nlmsghdr *nlh)
 {
@@ -382,7 +371,6 @@ mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen,
 		nlh = mnl_nlmsg_next(nlh, &len);
 	}
 }
-EXPORT_SYMBOL(mnl_nlmsg_fprintf);
 
 /**
  * \defgroup batch Netlink message batch helpers
@@ -456,7 +444,6 @@ struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, size_t limit)
 
 	return b;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_start);
 
 /**
  * mnl_nlmsg_batch_stop - release a batch
@@ -468,7 +455,6 @@ void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b)
 {
 	free(b);
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_stop);
 
 /**
  * mnl_nlmsg_batch_next - get room for the next message in the batch
@@ -493,7 +479,6 @@ bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b)
 	b->buflen += nlh->nlmsg_len;
 	return true;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_next);
 
 /**
  * mnl_nlmsg_batch_reset - reset the batch
@@ -516,7 +501,6 @@ void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b)
 		b->cur = b->buf;
 	}
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_reset);
 
 /**
  * mnl_nlmsg_batch_size - get current size of the batch
@@ -528,7 +512,6 @@ size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b)
 {
 	return b->buflen;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_size);
 
 /**
  * mnl_nlmsg_batch_head - get head of this batch
@@ -541,7 +524,6 @@ void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b)
 {
 	return b->buf;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_head);
 
 /**
  * mnl_nlmsg_batch_current - returns current position in the batch
@@ -554,7 +536,6 @@ void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b)
 {
 	return b->cur;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_current);
 
 /**
  * mnl_nlmsg_batch_is_empty - check if there is any message in the batch
@@ -566,7 +547,6 @@ bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b)
 {
 	return b->buflen == 0;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_is_empty);
 
 /**
  * @}
diff --git a/src/socket.c b/src/socket.c
index d63ab87..40f5c6f 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -7,6 +7,7 @@
  * (at your option) any later version.
  */
 
+#include "internal.h"
 #include <libmnl/libmnl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -14,7 +15,6 @@
 #include <unistd.h>
 #include <time.h>
 #include <errno.h>
-#include "internal.h"
 
 /**
  * \mainpage
@@ -86,7 +86,6 @@ int mnl_socket_get_fd(const struct mnl_socket *nl)
 {
 	return nl->fd;
 }
-EXPORT_SYMBOL(mnl_socket_get_fd);
 
 /**
  * mnl_socket_get_portid - obtain Netlink PortID from netlink socket
@@ -101,7 +100,6 @@ unsigned int mnl_socket_get_portid(const struct mnl_socket *nl)
 {
 	return nl->addr.nl_pid;
 }
-EXPORT_SYMBOL(mnl_socket_get_portid);
 
 static struct mnl_socket *__mnl_socket_open(int bus, int flags)
 {
@@ -131,7 +129,6 @@ struct mnl_socket *mnl_socket_open(int bus)
 {
 	return __mnl_socket_open(bus, 0);
 }
-EXPORT_SYMBOL(mnl_socket_open);
 
 /**
  * mnl_socket_open2 - open a netlink socket with appropriate flags
@@ -149,7 +146,6 @@ struct mnl_socket *mnl_socket_open2(int bus, int flags)
 {
 	return __mnl_socket_open(bus, flags);
 }
-EXPORT_SYMBOL(mnl_socket_open2);
 
 /**
  * mnl_socket_fdopen - associates a mnl_socket object with pre-existing socket.
@@ -183,7 +179,6 @@ struct mnl_socket *mnl_socket_fdopen(int fd)
 
 	return nl;
 }
-EXPORT_SYMBOL(mnl_socket_fdopen);
 
 /**
  * mnl_socket_bind - bind netlink socket
@@ -223,7 +218,6 @@ int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid)
 	}
 	return 0;
 }
-EXPORT_SYMBOL(mnl_socket_bind);
 
 /**
  * mnl_socket_sendto - send a netlink message of a certain size
@@ -243,7 +237,6 @@ mnl_socket_sendto(const struct mnl_socket *nl, const void *buf, size_t len)
 	return sendto(nl->fd, buf, len, 0, 
 		      (struct sockaddr *) &snl, sizeof(snl));
 }
-EXPORT_SYMBOL(mnl_socket_sendto);
 
 /**
  * mnl_socket_recvfrom - receive a netlink message
@@ -291,7 +284,6 @@ mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t bufsiz)
 	}
 	return ret;
 }
-EXPORT_SYMBOL(mnl_socket_recvfrom);
 
 /**
  * mnl_socket_close - close a given netlink socket
@@ -306,7 +298,6 @@ int mnl_socket_close(struct mnl_socket *nl)
 	free(nl);
 	return ret;
 }
-EXPORT_SYMBOL(mnl_socket_close);
 
 /**
  * mnl_socket_setsockopt - set Netlink socket option
@@ -338,7 +329,6 @@ int mnl_socket_setsockopt(const struct mnl_socket *nl, int type,
 {
 	return setsockopt(nl->fd, SOL_NETLINK, type, buf, len);
 }
-EXPORT_SYMBOL(mnl_socket_setsockopt);
 
 /**
  * mnl_socket_getsockopt - get a Netlink socket option
@@ -354,7 +344,6 @@ int mnl_socket_getsockopt(const struct mnl_socket *nl, int type,
 {
 	return getsockopt(nl->fd, SOL_NETLINK, type, buf, len);
 }
-EXPORT_SYMBOL(mnl_socket_getsockopt);
 
 /**
  * @}

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
  2015-10-29 19:07 [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags Mike Frysinger
@ 2015-11-01 22:09 ` Jan Engelhardt
  2015-11-14  0:45 ` Neutron Soutmun
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Engelhardt @ 2015-11-01 22:09 UTC (permalink / raw)
  To: 20151006012711.GA5372; +Cc: netfilter-devel, neo.neutron


On Thursday 2015-10-29 20:07, Mike Frysinger wrote:
>Neutron Soutmun wrote:
>> * libmnl using an export map (-Wl,--version-script=),
>>  hence, no need to explicitly use the EXPORT_SYMBOL() tags.
>
>this isn't entirely accurate.  the use of hidden visibility allows for
>optimizations (e.g. bypassing the PLT).  export maps merely control the
>final visibility of the symbols at link time ... gcc is forced to assume
>every function call otherwise is still globally visible (exported).

Though your argument makes sense, I find that `gcc -c` does not
really care about the visibility. It always emits, on x86_64, a
0xE8 __ __ __ __ opcode for a function call with C external linkage,
whether that function has hidden or default visibility. The linker
fills in the four bytes because only it knows how far to jump, after
combining the .o files.

And it appears to be smart enough not to issue a
"callq <st_intern@plt>":

$ cat x.c
extern void st_exported(void);
extern void st_intern(void);
void st_exported(void) { st_intern(); }
$ cat y.c
extern void st_intern(void);
void st_intern(void) {}
$ cat xy.sym
XY { global: st_exported; local: *; };
$ gcc x.c y.c -fPIC -Wall -shared -o xy.so -Wl,--version-script=xy.sym
$ objdump -d xy.so
0000000000000655 <st_exported>:
 655:	55                   	push   %rbp
 656:	48 89 e5             	mov    %rsp,%rbp
 659:	e8 02 00 00 00       	callq  660 <st_intern>
 65e:	5d                   	pop    %rbp
 65f:	c3                   	retq   
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
  2015-10-29 19:07 [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags Mike Frysinger
  2015-11-01 22:09 ` Jan Engelhardt
@ 2015-11-14  0:45 ` Neutron Soutmun
  2015-12-14 12:37   ` Pablo Neira Ayuso
  1 sibling, 1 reply; 8+ messages in thread
From: Neutron Soutmun @ 2015-11-14  0:45 UTC (permalink / raw)
  To: 20151006012711.GA5372, netfilter-devel, Neutron Soutmun

On Fri, Oct 30, 2015 at 2:07 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> Neutron Soutmun wrote:
>> * libmnl using an export map (-Wl,--version-script=),
>>  hence, no need to explicitly use the EXPORT_SYMBOL() tags.
>
> this isn't entirely accurate.  the use of hidden visibility allows for
> optimizations (e.g. bypassing the PLT).  export maps merely control the
> final visibility of the symbols at link time ... gcc is forced to assume
> every function call otherwise is still globally visible (exported).
>
> it doesn't make a big difference in the libmnl case as there aren't any
> real internal-only symbols, but in larger libraries, this sort of change
> increases code size and runtime overhead.
>
> this is why libraries take a different approach: set default visibility
> to hidden and then update the header with a macro like EXPORT.  there is
> only one file to declare the prototypes and the visibility markings are
> right there.  no need for EXPORT_SYMBOL() lines.  the export map is only
> really for toolchains that lack visibility support.

Thanks to point to this, it really make sense.

> something as simple as the patch below
> -mike

The initial problem for my proposed patch is the incompatible of
symbols visibility in gcc and clang
which libmnl is failed to build from source in clang and it's the one
of another approaches that pass the build in both gcc and clang.

I'll test your patch with clang and back to you ASAP.

Best regards,
Neutron Soutmun

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

* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
  2015-11-14  0:45 ` Neutron Soutmun
@ 2015-12-14 12:37   ` Pablo Neira Ayuso
  2015-12-14 17:34     ` Caroline Tice
  0 siblings, 1 reply; 8+ messages in thread
From: Pablo Neira Ayuso @ 2015-12-14 12:37 UTC (permalink / raw)
  To: Neutron Soutmun
  Cc: 20151006012711.GA5372, netfilter-devel, Mike Frysinger, Caroline Tice

Cc'ing everyone that has sent patches to us to address libmnl
compilation problems with clang.

On Sat, Nov 14, 2015 at 07:45:44AM +0700, Neutron Soutmun wrote:
> The initial problem for my proposed patch is the incompatible of
> symbols visibility in gcc and clang
> which libmnl is failed to build from source in clang and it's the one
> of another approaches that pass the build in both gcc and clang.
> 
> I'll test your patch with clang and back to you ASAP.

Did anyone consider going back to the clang community and ask why
EXPORT_SYMBOL() definition is not correct there?

I understand removing this from our libraries is a quick solution, but
I think it would be to get feedback from them to see if it's something
that they can fix there (it would resolve problems for projects a using
similar definition without updating the code).

Let me know, thanks.

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

* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
  2015-12-14 12:37   ` Pablo Neira Ayuso
@ 2015-12-14 17:34     ` Caroline Tice
  2015-12-14 17:37       ` Caroline Tice
  2015-12-14 19:25       ` Pablo Neira Ayuso
  0 siblings, 2 replies; 8+ messages in thread
From: Caroline Tice @ 2015-12-14 17:34 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Neutron Soutmun, 20151006012711.GA5372, netfilter-devel, Mike Frysinger

I did talk with some Clang developers initially, to try to determine
if this was in fact a Clang bug and therefore would need to be fixed
in Clang.  The answer I got was a resounding  no, this is not a Clang
bug; it is, in fact a GCC bug -- an example of GCC being overly
permissive (which, sadly, is not that uncommon).  After a function has
been *declared*  (the header, but no code), it is still ok to change
the visibility of the function.  However after the function has
actually been *defined*, changing the visibility of the function is
illegal.  That is why moving all of the EXPORT_SYMBOL statements from
after the function code to before the function code fixes the problem,
as far as Clang is concerned.

-- Caroline
cmtice@google.com


On Mon, Dec 14, 2015 at 4:37 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Cc'ing everyone that has sent patches to us to address libmnl
> compilation problems with clang.
>
> On Sat, Nov 14, 2015 at 07:45:44AM +0700, Neutron Soutmun wrote:
>> The initial problem for my proposed patch is the incompatible of
>> symbols visibility in gcc and clang
>> which libmnl is failed to build from source in clang and it's the one
>> of another approaches that pass the build in both gcc and clang.
>>
>> I'll test your patch with clang and back to you ASAP.
>
> Did anyone consider going back to the clang community and ask why
> EXPORT_SYMBOL() definition is not correct there?
>
> I understand removing this from our libraries is a quick solution, but
> I think it would be to get feedback from them to see if it's something
> that they can fix there (it would resolve problems for projects a using
> similar definition without updating the code).
>
> Let me know, thanks.

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

* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
  2015-12-14 17:34     ` Caroline Tice
@ 2015-12-14 17:37       ` Caroline Tice
  2015-12-14 19:25       ` Pablo Neira Ayuso
  1 sibling, 0 replies; 8+ messages in thread
From: Caroline Tice @ 2015-12-14 17:37 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Neutron Soutmun, 20151006012711.GA5372, netfilter-devel, Mike Frysinger

Trying again; the mailer rejected my initial email.

-- Caroline
cmtice@google.com


On Mon, Dec 14, 2015 at 9:34 AM, Caroline Tice <cmtice@google.com> wrote:
> I did talk with some Clang developers initially, to try to determine
> if this was in fact a Clang bug and therefore would need to be fixed
> in Clang.  The answer I got was a resounding  no, this is not a Clang
> bug; it is, in fact a GCC bug -- an example of GCC being overly
> permissive (which, sadly, is not that uncommon).  After a function has
> been *declared*  (the header, but no code), it is still ok to change
> the visibility of the function.  However after the function has
> actually been *defined*, changing the visibility of the function is
> illegal.  That is why moving all of the EXPORT_SYMBOL statements from
> after the function code to before the function code fixes the problem,
> as far as Clang is concerned.
>
> -- Caroline
> cmtice@google.com
>
>
> On Mon, Dec 14, 2015 at 4:37 AM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>> Cc'ing everyone that has sent patches to us to address libmnl
>> compilation problems with clang.
>>
>> On Sat, Nov 14, 2015 at 07:45:44AM +0700, Neutron Soutmun wrote:
>>> The initial problem for my proposed patch is the incompatible of
>>> symbols visibility in gcc and clang
>>> which libmnl is failed to build from source in clang and it's the one
>>> of another approaches that pass the build in both gcc and clang.
>>>
>>> I'll test your patch with clang and back to you ASAP.
>>
>> Did anyone consider going back to the clang community and ask why
>> EXPORT_SYMBOL() definition is not correct there?
>>
>> I understand removing this from our libraries is a quick solution, but
>> I think it would be to get feedback from them to see if it's something
>> that they can fix there (it would resolve problems for projects a using
>> similar definition without updating the code).
>>
>> Let me know, thanks.

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

* Re: [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
  2015-12-14 17:34     ` Caroline Tice
  2015-12-14 17:37       ` Caroline Tice
@ 2015-12-14 19:25       ` Pablo Neira Ayuso
  1 sibling, 0 replies; 8+ messages in thread
From: Pablo Neira Ayuso @ 2015-12-14 19:25 UTC (permalink / raw)
  To: Caroline Tice
  Cc: Neutron Soutmun, 20151006012711.GA5372, netfilter-devel, Mike Frysinger

On Mon, Dec 14, 2015 at 09:34:23AM -0800, Caroline Tice wrote:
> I did talk with some Clang developers initially, to try to determine
> if this was in fact a Clang bug and therefore would need to be fixed
> in Clang.  The answer I got was a resounding  no, this is not a Clang
> bug; it is, in fact a GCC bug -- an example of GCC being overly
> permissive (which, sadly, is not that uncommon).  After a function has
> been *declared*  (the header, but no code), it is still ok to change
> the visibility of the function.  However after the function has
> actually been *defined*, changing the visibility of the function is
> illegal.  That is why moving all of the EXPORT_SYMBOL statements from
> after the function code to before the function code fixes the problem,
> as far as Clang is concerned.

Thanks, so we already got feedback from them.

Then I think we upstream this patch:

http://patchwork.ozlabs.org/patch/537980/

But I'd suggest the MNL_EXPORT is renamed to EXPORT_SYMBOL and it is
placed in the .c files if possible, I don't think we need to expose
this through the library headers (every function declared there is
indeed exported, so that information is not relevant there).

Will anyone help sending a new version to end up with this issue?

Thanks.

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

* [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags
@ 2015-10-06  1:27 Neutron Soutmun
  0 siblings, 0 replies; 8+ messages in thread
From: Neutron Soutmun @ 2015-10-06  1:27 UTC (permalink / raw)
  To: netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 20929 bytes --]

* libmnl using an export map (-Wl,--version-script=),
  hence, no need to explicitly use the EXPORT_SYMBOL() tags.

  Drop the EXPORT_SYMBOL() tags also fix the failed to build with
  clang.

Signed-off-by: Neutron Soutmun <neo.neutron@gmail.com>
---
 Make_global.am        |  2 +-
 configure.ac          |  1 -
 m4/gcc4_visibility.m4 | 21 ---------------------
 src/Makefile.am       |  2 +-
 src/attr.c            | 37 +------------------------------------
 src/callback.c        |  4 +---
 src/internal.h        | 12 ------------
 src/nlmsg.c           | 22 +---------------------
 src/socket.c          | 12 +-----------
 9 files changed, 6 insertions(+), 107 deletions(-)
 delete mode 100644 m4/gcc4_visibility.m4
 delete mode 100644 src/internal.h

diff --git a/Make_global.am b/Make_global.am
index 3665b68..9b1667d 100644
--- a/Make_global.am
+++ b/Make_global.am
@@ -21,4 +21,4 @@
 LIBVERSION=1:0:1
 
 AM_CPPFLAGS = ${regular_CPPFLAGS} -I${top_srcdir}/include
-AM_CFLAGS = ${regular_CFLAGS} ${GCC_FVISIBILITY_HIDDEN}
+AM_CFLAGS = ${regular_CFLAGS}
diff --git a/configure.ac b/configure.ac
index 313a015..4cb59a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,6 @@ AM_PROG_CC_C_O
 AC_EXEEXT
 AC_DISABLE_STATIC
 LT_INIT
-CHECK_GCC_FVISIBILITY
 case "$host" in
 *-*-linux* | *-*-uclinux*) ;;
 *) AC_MSG_ERROR([Linux only, dude!]);;
diff --git a/m4/gcc4_visibility.m4 b/m4/gcc4_visibility.m4
deleted file mode 100644
index 214d3f3..0000000
--- a/m4/gcc4_visibility.m4
+++ /dev/null
@@ -1,21 +0,0 @@
-
-# GCC 4.x -fvisibility=hidden
-
-AC_DEFUN([CHECK_GCC_FVISIBILITY], [
-	AC_LANG_PUSH([C])
-	saved_CFLAGS="$CFLAGS"
-	CFLAGS="$saved_CFLAGS -fvisibility=hidden"
-	AC_CACHE_CHECK([whether compiler accepts -fvisibility=hidden],
-	  [ac_cv_fvisibility_hidden], AC_COMPILE_IFELSE(
-		[AC_LANG_SOURCE()],
-		[ac_cv_fvisibility_hidden=yes],
-		[ac_cv_fvisibility_hidden=no]
-	))
-	if test "$ac_cv_fvisibility_hidden" = "yes"; then
-		AC_DEFINE([HAVE_VISIBILITY_HIDDEN], [1],
-			[True if compiler supports -fvisibility=hidden])
-		AC_SUBST([GCC_FVISIBILITY_HIDDEN], [-fvisibility=hidden])
-	fi
-	CFLAGS="$saved_CFLAGS"
-	AC_LANG_POP([C])
-])
diff --git a/src/Makefile.am b/src/Makefile.am
index 9aab516..6150049 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,4 +2,4 @@ include $(top_srcdir)/Make_global.am
 lib_LTLIBRARIES = libmnl.la
 
 libmnl_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libmnl.map -version-info $(LIBVERSION)
-libmnl_la_SOURCES = socket.c callback.c nlmsg.c attr.c internal.h libmnl.map
+libmnl_la_SOURCES = socket.c callback.c nlmsg.c attr.c libmnl.map
diff --git a/src/attr.c b/src/attr.c
index c551d0b..274a6ee 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -10,7 +10,7 @@
 #include <libmnl/libmnl.h>
 #include <string.h>
 #include <errno.h>
-#include "internal.h"
+#include "config.h"
 
 /**
  * \defgroup attr Netlink attribute helpers
@@ -39,7 +39,6 @@ uint16_t mnl_attr_get_type(const struct nlattr *attr)
 {
 	return attr->nla_type & NLA_TYPE_MASK;
 }
-EXPORT_SYMBOL(mnl_attr_get_type);
 
 /**
  * mnl_attr_get_len - get length of netlink attribute
@@ -52,7 +51,6 @@ uint16_t mnl_attr_get_len(const struct nlattr *attr)
 {
 	return attr->nla_len;
 }
-EXPORT_SYMBOL(mnl_attr_get_len);
 
 /**
  * mnl_attr_get_payload_len - get the attribute payload-value length
@@ -64,7 +62,6 @@ uint16_t mnl_attr_get_payload_len(const struct nlattr *attr)
 {
 	return attr->nla_len - MNL_ATTR_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_attr_get_payload_len);
 
 /**
  * mnl_attr_get_payload - get pointer to the attribute payload
@@ -76,7 +73,6 @@ void *mnl_attr_get_payload(const struct nlattr *attr)
 {
 	return (void *)attr + MNL_ATTR_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_attr_get_payload);
 
 /**
  * mnl_attr_ok - check if there is room for an attribute in a buffer
@@ -100,7 +96,6 @@ bool mnl_attr_ok(const struct nlattr *attr, int len)
 	       attr->nla_len >= sizeof(struct nlattr) &&
 	       (int)attr->nla_len <= len;
 }
-EXPORT_SYMBOL(mnl_attr_ok);
 
 /**
  * mnl_attr_next - get the next attribute in the payload of a netlink message
@@ -114,7 +109,6 @@ struct nlattr *mnl_attr_next(const struct nlattr *attr)
 {
 	return (struct nlattr *)((void *)attr + MNL_ALIGN(attr->nla_len));
 }
-EXPORT_SYMBOL(mnl_attr_next);
 
 /**
  * mnl_attr_type_valid - check if the attribute type is valid
@@ -138,7 +132,6 @@ int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max)
 	}
 	return 1;
 }
-EXPORT_SYMBOL(mnl_attr_type_valid);
 
 static int __mnl_attr_validate(const struct nlattr *attr,
 			       enum mnl_attr_data_type type, size_t exp_len)
@@ -222,7 +215,6 @@ int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type)
 	exp_len = mnl_attr_data_type_len[type];
 	return __mnl_attr_validate(attr, type, exp_len);
 }
-EXPORT_SYMBOL(mnl_attr_validate);
 
 /**
  * mnl_attr_validate2 - validate netlink attribute (extended version)
@@ -244,7 +236,6 @@ mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type,
 	}
 	return __mnl_attr_validate(attr, type, exp_len);
 }
-EXPORT_SYMBOL(mnl_attr_validate2);
 
 /**
  * mnl_attr_parse - parse attributes
@@ -273,7 +264,6 @@ mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset,
 			return ret;
 	return ret;
 }
-EXPORT_SYMBOL(mnl_attr_parse);
 
 /**
  * mnl_attr_parse_nested - parse attributes inside a nest
@@ -301,7 +291,6 @@ mnl_attr_parse_nested(const struct nlattr *nested, mnl_attr_cb_t cb,
 			return ret;
 	return ret;
 }
-EXPORT_SYMBOL(mnl_attr_parse_nested);
 
 /**
  * mnl_attr_parse_payload - parse attributes in payload of Netlink message
@@ -334,7 +323,6 @@ mnl_attr_parse_payload(const void *payload, size_t payload_len,
 			return ret;
 	return ret;
 }
-EXPORT_SYMBOL(mnl_attr_parse_payload);
 
 /**
  * mnl_attr_get_u8 - returns 8-bit unsigned integer attribute payload
@@ -346,7 +334,6 @@ uint8_t mnl_attr_get_u8(const struct nlattr *attr)
 {
 	return *((uint8_t *)mnl_attr_get_payload(attr));
 }
-EXPORT_SYMBOL(mnl_attr_get_u8);
 
 /**
  * mnl_attr_get_u16 - returns 16-bit unsigned integer attribute payload
@@ -358,7 +345,6 @@ uint16_t mnl_attr_get_u16(const struct nlattr *attr)
 {
 	return *((uint16_t *)mnl_attr_get_payload(attr));
 }
-EXPORT_SYMBOL(mnl_attr_get_u16);
 
 /**
  * mnl_attr_get_u32 - returns 32-bit unsigned integer attribute payload
@@ -370,7 +356,6 @@ uint32_t mnl_attr_get_u32(const struct nlattr *attr)
 {
 	return *((uint32_t *)mnl_attr_get_payload(attr));
 }
-EXPORT_SYMBOL(mnl_attr_get_u32);
 
 /**
  * mnl_attr_get_u64 - returns 64-bit unsigned integer attribute.
@@ -386,7 +371,6 @@ uint64_t mnl_attr_get_u64(const struct nlattr *attr)
 	memcpy(&tmp, mnl_attr_get_payload(attr), sizeof(tmp));
 	return tmp;
 }
-EXPORT_SYMBOL(mnl_attr_get_u64);
 
 /**
  * mnl_attr_get_str - returns pointer to string attribute.
@@ -398,7 +382,6 @@ const char *mnl_attr_get_str(const struct nlattr *attr)
 {
 	return mnl_attr_get_payload(attr);
 }
-EXPORT_SYMBOL(mnl_attr_get_str);
 
 /**
  * mnl_attr_put - add an attribute to netlink message
@@ -421,7 +404,6 @@ mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
 	memcpy(mnl_attr_get_payload(attr), data, len);
 	nlh->nlmsg_len += MNL_ALIGN(payload_len);
 }
-EXPORT_SYMBOL(mnl_attr_put);
 
 /**
  * mnl_attr_put_u8 - add 8-bit unsigned integer attribute to netlink message
@@ -436,7 +418,6 @@ void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint8_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u8);
 
 /**
  * mnl_attr_put_u16 - add 16-bit unsigned integer attribute to netlink message
@@ -451,7 +432,6 @@ void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint16_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u16);
 
 /**
  * mnl_attr_put_u32 - add 32-bit unsigned integer attribute to netlink message
@@ -466,7 +446,6 @@ void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint32_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u32);
 
 /**
  * mnl_attr_put_u64 - add 64-bit unsigned integer attribute to netlink message
@@ -481,7 +460,6 @@ void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data)
 {
 	mnl_attr_put(nlh, type, sizeof(uint64_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u64);
 
 /**
  * mnl_attr_put_str - add string attribute to netlink message
@@ -496,7 +474,6 @@ void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data)
 {
 	mnl_attr_put(nlh, type, strlen(data), data);
 }
-EXPORT_SYMBOL(mnl_attr_put_str);
 
 /**
  * mnl_attr_put_strz - add string attribute to netlink message
@@ -514,7 +491,6 @@ void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data)
 {
 	mnl_attr_put(nlh, type, strlen(data)+1, data);
 }
-EXPORT_SYMBOL(mnl_attr_put_strz);
 
 /**
  * mnl_attr_nest_start - start an attribute nest
@@ -535,7 +511,6 @@ struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type)
 
 	return start;
 }
-EXPORT_SYMBOL(mnl_attr_nest_start);
 
 /**
  * mnl_attr_put_check - add an attribute to netlink message
@@ -560,7 +535,6 @@ mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen,
 	mnl_attr_put(nlh, type, len, data);
 	return true;
 }
-EXPORT_SYMBOL(mnl_attr_put_check);
 
 /**
  * mnl_attr_put_u8_check - add 8-bit unsigned int attribute to netlink message
@@ -581,7 +555,6 @@ mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint8_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u8_check);
 
 /**
  * mnl_attr_put_u16_check - add 16-bit unsigned int attribute to netlink message
@@ -604,7 +577,6 @@ mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint16_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u16_check);
 
 /**
  * mnl_attr_put_u32_check - add 32-bit unsigned int attribute to netlink message
@@ -627,7 +599,6 @@ mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint32_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u32_check);
 
 /**
  * mnl_attr_put_u64_check - add 64-bit unsigned int attribute to netlink message
@@ -650,7 +621,6 @@ mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, sizeof(uint64_t), &data);
 }
-EXPORT_SYMBOL(mnl_attr_put_u64_check);
 
 /**
  * mnl_attr_put_str_check - add string attribute to netlink message
@@ -673,7 +643,6 @@ mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, strlen(data), data);
 }
-EXPORT_SYMBOL(mnl_attr_put_str_check);
 
 /**
  * mnl_attr_put_strz_check - add string attribute to netlink message
@@ -697,7 +666,6 @@ mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen,
 {
 	return mnl_attr_put_check(nlh, buflen, type, strlen(data)+1, data);
 }
-EXPORT_SYMBOL(mnl_attr_put_strz_check);
 
 /**
  * mnl_attr_nest_start_check - start an attribute nest
@@ -716,7 +684,6 @@ mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type)
 		return NULL;
 	return mnl_attr_nest_start(nlh, type);
 }
-EXPORT_SYMBOL(mnl_attr_nest_start_check);
 
 /**
  * mnl_attr_nest_end - end an attribute nest
@@ -730,7 +697,6 @@ mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start)
 {
 	start->nla_len = mnl_nlmsg_get_payload_tail(nlh) - (void *)start;
 }
-EXPORT_SYMBOL(mnl_attr_nest_end);
 
 /**
  * mnl_attr_nest_cancel - cancel an attribute nest
@@ -744,7 +710,6 @@ mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start)
 {
 	nlh->nlmsg_len -= mnl_nlmsg_get_payload_tail(nlh) - (void *)start;
 }
-EXPORT_SYMBOL(mnl_attr_nest_cancel);
 
 /**
  * @}
diff --git a/src/callback.c b/src/callback.c
index f023401..5094d15 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -9,7 +9,7 @@
 
 #include <errno.h>
 #include <libmnl/libmnl.h>
-#include "internal.h"
+#include "config.h"
 
 static int mnl_cb_noop(const struct nlmsghdr *nlh, void *data)
 {
@@ -134,7 +134,6 @@ mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq,
 	return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data,
 			    cb_ctl_array, cb_ctl_array_len);
 }
-EXPORT_SYMBOL(mnl_cb_run2);
 
 /**
  * mnl_cb_run - callback runqueue for netlink messages (simplified version)
@@ -161,7 +160,6 @@ mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq,
 {
 	return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data, NULL, 0);
 }
-EXPORT_SYMBOL(mnl_cb_run);
 
 /**
  * @}
diff --git a/src/internal.h b/src/internal.h
deleted file mode 100644
index 3a88d1a..0000000
--- a/src/internal.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef INTERNAL_H
-#define INTERNAL_H 1
-
-#include "config.h"
-#ifdef HAVE_VISIBILITY_HIDDEN
-#	define __visible	__attribute__((visibility("default")))
-#	define EXPORT_SYMBOL(x)	typeof(x) (x) __visible
-#else
-#	define EXPORT_SYMBOL
-#endif
-
-#endif
diff --git a/src/nlmsg.c b/src/nlmsg.c
index fd2f698..3914562 100644
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -13,7 +13,7 @@
 #include <errno.h>
 #include <string.h>
 #include <libmnl/libmnl.h>
-#include "internal.h"
+#include "config.h"
 
 /**
  * \defgroup nlmsg Netlink message helpers
@@ -55,7 +55,6 @@ size_t mnl_nlmsg_size(size_t len)
 {
 	return len + MNL_NLMSG_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_nlmsg_size);
 
 /**
  * mnl_nlmsg_get_payload_len - get the length of the Netlink payload
@@ -68,7 +67,6 @@ size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh)
 {
 	return nlh->nlmsg_len - MNL_NLMSG_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload_len);
 
 /**
  * mnl_nlmsg_put_header - reserve and prepare room for Netlink header
@@ -88,7 +86,6 @@ struct nlmsghdr *mnl_nlmsg_put_header(void *buf)
 	nlh->nlmsg_len = len;
 	return nlh;
 }
-EXPORT_SYMBOL(mnl_nlmsg_put_header);
 
 /**
  * mnl_nlmsg_put_extra_header - reserve and prepare room for an extra header
@@ -110,7 +107,6 @@ mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size)
 	memset(ptr, 0, len);
 	return ptr;
 }
-EXPORT_SYMBOL(mnl_nlmsg_put_extra_header);
 
 /**
  * mnl_nlmsg_get_payload - get a pointer to the payload of the netlink message
@@ -122,7 +118,6 @@ void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh)
 {
 	return (void *)nlh + MNL_NLMSG_HDRLEN;
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload);
 
 /**
  * mnl_nlmsg_get_payload_offset - get a pointer to the payload of the message
@@ -137,7 +132,6 @@ mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset)
 {
 	return (void *)nlh + MNL_NLMSG_HDRLEN + MNL_ALIGN(offset);
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload_offset);
 
 /**
  * mnl_nlmsg_ok - check a there is room for netlink message
@@ -161,7 +155,6 @@ bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len)
 	       nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
 	       (int)nlh->nlmsg_len <= len;
 }
-EXPORT_SYMBOL(mnl_nlmsg_ok);
 
 /**
  * mnl_nlmsg_next - get the next netlink message in a multipart message
@@ -182,7 +175,6 @@ mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len)
 	*len -= MNL_ALIGN(nlh->nlmsg_len);
 	return (struct nlmsghdr *)((void *)nlh + MNL_ALIGN(nlh->nlmsg_len));
 }
-EXPORT_SYMBOL(mnl_nlmsg_next);
 
 /**
  * mnl_nlmsg_get_payload_tail - get the ending of the netlink message
@@ -196,7 +188,6 @@ void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh)
 {
 	return (void *)nlh + MNL_ALIGN(nlh->nlmsg_len);
 }
-EXPORT_SYMBOL(mnl_nlmsg_get_payload_tail);
 
 /**
  * mnl_nlmsg_seq_ok - perform sequence tracking
@@ -217,7 +208,6 @@ mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq)
 {
 	return nlh->nlmsg_seq && seq ? nlh->nlmsg_seq == seq : true;
 }
-EXPORT_SYMBOL(mnl_nlmsg_seq_ok);
 
 /**
  * mnl_nlmsg_portid_ok - perform portID origin check
@@ -238,7 +228,6 @@ mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, unsigned int portid)
 {
 	return nlh->nlmsg_pid && portid ? nlh->nlmsg_pid == portid : true;
 }
-EXPORT_SYMBOL(mnl_nlmsg_portid_ok);
 
 static void mnl_nlmsg_fprintf_header(FILE *fd, const struct nlmsghdr *nlh)
 {
@@ -382,7 +371,6 @@ mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen,
 		nlh = mnl_nlmsg_next(nlh, &len);
 	}
 }
-EXPORT_SYMBOL(mnl_nlmsg_fprintf);
 
 /**
  * \defgroup batch Netlink message batch helpers
@@ -456,7 +444,6 @@ struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, size_t limit)
 
 	return b;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_start);
 
 /**
  * mnl_nlmsg_batch_stop - release a batch
@@ -468,7 +455,6 @@ void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b)
 {
 	free(b);
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_stop);
 
 /**
  * mnl_nlmsg_batch_next - get room for the next message in the batch
@@ -493,7 +479,6 @@ bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b)
 	b->buflen += nlh->nlmsg_len;
 	return true;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_next);
 
 /**
  * mnl_nlmsg_batch_reset - reset the batch
@@ -516,7 +501,6 @@ void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b)
 		b->cur = b->buf;
 	}
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_reset);
 
 /**
  * mnl_nlmsg_batch_size - get current size of the batch
@@ -528,7 +512,6 @@ size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b)
 {
 	return b->buflen;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_size);
 
 /**
  * mnl_nlmsg_batch_head - get head of this batch
@@ -541,7 +524,6 @@ void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b)
 {
 	return b->buf;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_head);
 
 /**
  * mnl_nlmsg_batch_current - returns current position in the batch
@@ -554,7 +536,6 @@ void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b)
 {
 	return b->cur;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_current);
 
 /**
  * mnl_nlmsg_batch_is_empty - check if there is any message in the batch
@@ -566,7 +547,6 @@ bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b)
 {
 	return b->buflen == 0;
 }
-EXPORT_SYMBOL(mnl_nlmsg_batch_is_empty);
 
 /**
  * @}
diff --git a/src/socket.c b/src/socket.c
index 86657d4..c6e7a62 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -14,7 +14,7 @@
 #include <unistd.h>
 #include <time.h>
 #include <errno.h>
-#include "internal.h"
+#include "config.h"
 
 /**
  * \mainpage
@@ -86,7 +86,6 @@ int mnl_socket_get_fd(const struct mnl_socket *nl)
 {
 	return nl->fd;
 }
-EXPORT_SYMBOL(mnl_socket_get_fd);
 
 /**
  * mnl_socket_get_portid - obtain Netlink PortID from netlink socket
@@ -101,7 +100,6 @@ unsigned int mnl_socket_get_portid(const struct mnl_socket *nl)
 {
 	return nl->addr.nl_pid;
 }
-EXPORT_SYMBOL(mnl_socket_get_portid);
 
 /**
  * mnl_socket_open - open a netlink socket
@@ -126,7 +124,6 @@ struct mnl_socket *mnl_socket_open(int bus)
 
 	return nl;
 }
-EXPORT_SYMBOL(mnl_socket_open);
 
 /**
  * mnl_socket_fdopen - associates a mnl_socket object with pre-existing socket.
@@ -160,7 +157,6 @@ struct mnl_socket *mnl_socket_fdopen(int fd)
 
 	return nl;
 }
-EXPORT_SYMBOL(mnl_socket_fdopen);
 
 /**
  * mnl_socket_bind - bind netlink socket
@@ -200,7 +196,6 @@ int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid)
 	}
 	return 0;
 }
-EXPORT_SYMBOL(mnl_socket_bind);
 
 /**
  * mnl_socket_sendto - send a netlink message of a certain size
@@ -220,7 +215,6 @@ mnl_socket_sendto(const struct mnl_socket *nl, const void *buf, size_t len)
 	return sendto(nl->fd, buf, len, 0, 
 		      (struct sockaddr *) &snl, sizeof(snl));
 }
-EXPORT_SYMBOL(mnl_socket_sendto);
 
 /**
  * mnl_socket_recvfrom - receive a netlink message
@@ -268,7 +262,6 @@ mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t bufsiz)
 	}
 	return ret;
 }
-EXPORT_SYMBOL(mnl_socket_recvfrom);
 
 /**
  * mnl_socket_close - close a given netlink socket
@@ -283,7 +276,6 @@ int mnl_socket_close(struct mnl_socket *nl)
 	free(nl);
 	return ret;
 }
-EXPORT_SYMBOL(mnl_socket_close);
 
 /**
  * mnl_socket_setsockopt - set Netlink socket option
@@ -315,7 +307,6 @@ int mnl_socket_setsockopt(const struct mnl_socket *nl, int type,
 {
 	return setsockopt(nl->fd, SOL_NETLINK, type, buf, len);
 }
-EXPORT_SYMBOL(mnl_socket_setsockopt);
 
 /**
  * mnl_socket_getsockopt - get a Netlink socket option
@@ -331,7 +322,6 @@ int mnl_socket_getsockopt(const struct mnl_socket *nl, int type,
 {
 	return getsockopt(nl->fd, SOL_NETLINK, type, buf, len);
 }
-EXPORT_SYMBOL(mnl_socket_getsockopt);
 
 /**
  * @}
-- 
2.5.3


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-12-14 19:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 19:07 [PATCH v4] libmnl: Drop the EXPORT_SYMBOL() tags Mike Frysinger
2015-11-01 22:09 ` Jan Engelhardt
2015-11-14  0:45 ` Neutron Soutmun
2015-12-14 12:37   ` Pablo Neira Ayuso
2015-12-14 17:34     ` Caroline Tice
2015-12-14 17:37       ` Caroline Tice
2015-12-14 19:25       ` Pablo Neira Ayuso
  -- strict thread matches above, loose matches on Subject: below --
2015-10-06  1:27 Neutron Soutmun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.