[systemd-devel] [PATCH] Add -lresolv to libudev LIBADD

Łukasz Stelmach l.stelmach at samsung.com
Fri Feb 21 07:58:15 PST 2014


It was <2014-02-21 pią 16:22>, when Lennart Poettering wrote:
> On Fri, 21.02.14 15:54, Łukasz Stelmach (l.stelmach at samsung.com) wrote:
>
>> Fix problems with unresolved symbols when building on Ubuntu 12.04 x86_64.
>> 
>> --8<---------------cut here---------------start------------->8---
>> ./.libs/libudev.so: undefined reference to `__res_search'
>> ./.libs/libudev.so: undefined reference to `__res_query'
>> collect2: ld returned 1 exit status
>> --8<---------------cut here---------------end--------------->8---
>
> This doesn't look right. libudev really shouldn't need libresolv. We
> should figure out how these calls got pulled in...

Let me go step-by-step:

--8<---------------cut here---------------start------------->8---
$ strings ./.libs/libudev.so | grep __res_'\(query\|search\)'

__res_query
__res_search

# libudev needs libsystemd-internal
$ strings ./.libs/libsystemd-internal.a | grep __res_'\(query\|search\)'

__res_query
__res_search

$ grep __res_query [list of objects used to build l-i.a]

Binary file src/libsystemd/sd-resolve/.libs/libsystemd_internal_la-sd-resolve.o matches

$ rm -f src/libsystemd/sd-resolve/libsystemd_internal_la-sd-resolve.lo \
  && strace make src/libsystemd/sd-resolve/libsystemd_internal_la-sd-resolve.lo

$ grep __res_'\(query\|search\)' /usr/include/resolv.h

#define res_query               __res_query
#define res_querydomain         __res_querydomain
#define res_search              __res_search

$ gcc -std=gnu99 [...]-E src/libsystemd/sd-resolve/sd-resolve.c  -fPIC \
-DPIC | grep __res_'\(query\|search\)'

void __res_close (void) __attribute__ ((__nothrow__ , __leaf__));
int __res_init (void) __attribute__ ((__nothrow__ , __leaf__));
int __res_isourserver (const struct sockaddr_in *) __attribute__ ((__nothrow__ , __leaf__));
int __res_mkquery (int, const char *, int, int, const u_char *,
        int, const u_char *, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
int __res_query (const char *, int, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
int __res_querydomain (const char *, const char *, int, int,
     u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
int __res_search (const char *, int, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));
int __res_send (const u_char *, int, u_char *, int) __attribute__ ((__nothrow__ , __leaf__));

# 327 "/usr/include/resolv.h" 3 4

int __res_hnok (const char *) __attribute__ ((__nothrow__ , __leaf__));
--
                 do { if ((__builtin_expect(!!(!(length == sizeof(ResRequest) + res_req->dname_len)),0))) log_assert_failed("length == sizeof(ResRequest) + res_req->dname_len", "src/libsystemd/sd-resolve/sd-resolve.c", 425, __PRETTY_FUNCTION__); } while (0);

                 dname = (const char *) req + sizeof(ResRequest);

                 if (req->type == REQUEST_RES_QUERY)
                         ret = __res_query(dname, res_req->class, res_req->type, (unsigned char *) &answer, 10240);
                 else
                         ret = __res_search(dname, res_req->class, res_req->type, (unsigned char *) &answer, 10240);

                 return send_res_reply(out_fd, req->id, (unsigned char *) &answer, ret, (*__errno_location ()), (*__h_errno_location ()));
        }

        case REQUEST_TERMINATE:
--8<---------------cut here---------------end--------------->8---

There are defines in resolv.h which make res_query() and res_search() be
substituted with __res_.* versions. These does not look like Ubuntu
specific stuff[1].

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/resolv.h;h=53c3bba182be49ba0a2372ffba7920c016029ecd;hb=HEAD#l262

-- 
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20140221/420518b4/attachment.pgp>


More information about the systemd-devel mailing list