From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [libnftnl PATCH] Rename xfree() to libnftnl_xfree() to avoid symbol naming conflict
Date: Wed, 20 Aug 2014 00:02:36 +0200 [thread overview]
Message-ID: <20140819220236.GA7136@salvia> (raw)
In-Reply-To: <1408196389-15559-1-git-send-email-thomas.petazzoni@free-electrons.com>
[-- Attachment #1: Type: text/plain, Size: 826 bytes --]
On Sat, Aug 16, 2014 at 03:39:49PM +0200, Thomas Petazzoni wrote:
> When ELF binaries and shared libraries are used, the internal
> functions of libnftnl such as xfree() are not visible to the outside
> world (their visibility is 'hidden'). Therefore, the fact that other
> programs (especially nftables) may have symbols with the same name
> does not cause any problem.
>
> However, when doing static linking on a non-ELF platform (such as
> Blackfin, which uses the FLAT binary format), there is no way of
> encoding this visibility. Therefore, the xfree() symbols of libnftnl
> becomes visible to the outside world, causing a conflict with the
> xfree() symbol defined by nftables.
>
> To solve this, this patch renames the libnftnl xfree() function to
> libnftnl_xfree().
Would this small patch solve your problem too?
[-- Attachment #2: x.patch --]
[-- Type: text/x-diff, Size: 994 bytes --]
diff --git a/src/internal.h b/src/internal.h
index e76a5cb..c8dea7e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -16,6 +16,8 @@
#include <libnftnl/common.h>
#include <linux/netfilter/nf_tables.h>
+#define xfree(ptr) free((void *)ptr);
+
#define BASE_DEC 10
#define BASE_HEX 16
@@ -144,8 +146,6 @@ int nft_event_footer_snprintf(char *buf, size_t bufsize,
uint32_t format, uint32_t flags);
int nft_event_footer_fprintf(FILE *fp, uint32_t format, uint32_t flags);
-void xfree(const void *ptr);
-
struct expr_ops;
struct nft_rule_expr {
diff --git a/src/utils.c b/src/utils.c
index 1878390..96c8bf2 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -180,11 +180,6 @@ int nft_str2verdict(const char *verdict, int *verdict_num)
return -1;
}
-void xfree(const void *ptr)
-{
- free((void *)ptr);
-}
-
int nft_fprintf(FILE *fp, void *obj, uint32_t type, uint32_t flags,
int (*snprintf_cb)(char *buf, size_t bufsiz, void *obj,
uint32_t type, uint32_t flags))
next prev parent reply other threads:[~2014-08-19 22:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-16 13:39 [libnftnl PATCH] Rename xfree() to libnftnl_xfree() to avoid symbol naming conflict Thomas Petazzoni
2014-08-19 22:02 ` Pablo Neira Ayuso [this message]
2014-08-20 12:07 ` Thomas Petazzoni
2014-08-20 13:00 ` Jan Engelhardt
2014-08-20 13:22 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140819220236.GA7136@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).