Signed-off-by: Max <max.suraev(a)fairwaves.co>
---
tests/Makefile.am | 1 +
tests/gb/gprs_bssgp_test.c | 20 +-------------------
2 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6f76e5a..a739ab9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -69,6 +69,7 @@ gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la
$(top_builddir)/src/
gb_gprs_bssgp_test_SOURCES = gb/gprs_bssgp_test.c
gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la
$(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL)
+gb_gprs_bssgp_test_LDFLAGS = -static -Wl,--wrap=gprs_ns_sendmsg
gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c
gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la
$(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL)
diff --git a/tests/gb/gprs_bssgp_test.c b/tests/gb/gprs_bssgp_test.c
index 14ba4d1..4fb24df 100644
--- a/tests/gb/gprs_bssgp_test.c
+++ b/tests/gb/gprs_bssgp_test.c
@@ -34,24 +34,6 @@
static struct osmo_prim_hdr last_oph = {0};
/* override */
-ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
- const struct sockaddr *dest_addr, socklen_t addrlen)
-{
- typedef ssize_t (*sendto_t)(int, const void *, size_t, int,
- const struct sockaddr *, socklen_t);
- static sendto_t real_sendto = NULL;
- uint32_t dest_host = htonl(((struct sockaddr_in *)dest_addr)->sin_addr.s_addr);
-
- if (!real_sendto)
- real_sendto = dlsym(RTLD_NEXT, "sendto");
-
- fprintf(stderr, "MESSAGE to 0x%08x, msg length %d\n%s\n",
- dest_host, len, osmo_hexdump(buf, len));
-
- return len;
-}
-
-/* override */
int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
struct msgb *msg, uint16_t bvci)
{
@@ -64,7 +46,7 @@ int gprs_ns_callback(enum gprs_ns_evt event, struct gprs_nsvc *nsvc,
struct msgb *last_ns_tx_msg = NULL;
/* override */
-int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg)
+int __wrap_gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg)
{
msgb_free(last_ns_tx_msg);
last_ns_tx_msg = msg;
--
2.1.4
Show replies by date
On 06 Jul 2015, at 18:16, Max
<max.suraev(a)fairwaves.co> wrote:
Hi Max,
please provide a detailed and comprehensive commit message. You should
explain which compiler flags lead to which code generation which makes it
impossible to interpose the system library.
holger
On 06 Jul 2015, at 18:16, Max
<max.suraev(a)fairwaves.co> wrote:
Dear Max,
gb_gprs_bssgp_test_SOURCES = gb/gprs_bssgp_test.c
gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la
$(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL)
+gb_gprs_bssgp_test_LDFLAGS = -static -Wl,--wrap=gprs_ns_sendmsg
we still run into this issue when building for Ubuntu and the answer is that they pass
-Bsymbolic-functions and this means that the internal calls to gprs_ns_sendmsg are linked
directly so we can not interpose.
Your change forces static linking so the gprs_ns_sendmsg is resolved differently and
allows us to interpose one way or another. The issue with -static is that we now have an
optional static build.
I am tempted to just put LDFLAGS := $(LDFLAGS:-Wl,-Bsymbolic-functions=) into the
debian/rules. The library will not perform worse than on other platforms.
The other architectural change is to be able to "plug" transport so we can
provide our own send functions.
While we're at it we might also enable link-time optimization (LTO) globally by
adding -flto to gcc/linker flags.
See
https://gcc.gnu.org/wiki/LinkTimeOptimization for details.
This should offset whatever potential benefits direct linking had and might improve
performance in general.
18.01.2016 13:13, Holger Freyther пишет:
I am tempted to just put LDFLAGS :=
$(LDFLAGS:-Wl,-Bsymbolic-functions=) into the debian/rules. The library will not perform
worse than on other platforms.
cheers,
Max.