From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by sourceware.org (Postfix) with ESMTPS id B46303890016 for ; Wed, 23 Jun 2021 20:03:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B46303890016 Received: by mail-oo1-xc31.google.com with SMTP id v11-20020a4a8c4b0000b029024be8350c45so1018385ooj.12 for ; Wed, 23 Jun 2021 13:03:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=nBGgfNXmjjtR1fqipV8E/hJ122pYb8gT1hLvbqwLEug=; b=Puy0ImyneXBF8nZuxDhDTbYPtd9WkDNj8wegFSiuIi9Y0I6FDw437knQBYty6c527U CPzSHP3Ydu6ToJKFs7RU9gSh2kX6V1JlpFVOYfuWPPwHzRdp8b6CsGuDLCUGIRE9l4JQ KU7nQYgQtOWw/2A5Y4JBAhWpTPGF5adQvkfOg1mV2eqSjNpEQ92x5bPW+nfCl3ChlvsT 5J/xT7LEXe2dWqkenZJ/8bDhZEfKg+pg7wt/FIAfwzzpkCCBAxNNmtpVh60dqUTT2fVu zD+AU8aYqucFH6WBJjmBwlSLkCBH6wYh2qLSBdJ1c9rpkK0EGLnZAjBp4SarkmYH6VIJ vqGw== X-Gm-Message-State: AOAM530ep/7yPJDV0mFBPU3GD5sEpQpVP7lF5QqJnXOgqa33gHF8Bete xuv5Bg5nD5hvatJD7DAuLFe54PG6sGx8BUyh+KCis0ieudr2kQ== X-Google-Smtp-Source: ABdhPJxtPHgQMaMAmamR8dPb4hhLsmtm5WSmAT2fxTijV250zMu+2Ongk3z9XjmeGctDYxID9MFwDogogIe+ayakKj0= X-Received: by 2002:a4a:bb89:: with SMTP id h9mr1230537oop.69.1624478595835; Wed, 23 Jun 2021 13:03:15 -0700 (PDT) MIME-Version: 1.0 From: George Hodgkins Date: Wed, 23 Jun 2021 14:03:05 -0600 Message-ID: Subject: Diagnosing symbol conflicts in modified glibc build To: libc-help@sourceware.org X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-help@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-help mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 20:03:18 -0000 Hi all, I'm a grad student working on modifying glibc for research purposes. Our modifications interpose on or replace the public functions for some file descriptor operations (open/openat/creat/close/socket/bind/connect) and virtual memory control (mmap/sbrk/brk/munmap). Our code is contained in three files: one in /misc that implements core system functionality, and two in /sysdeps/unix/sysv/linux that implement the file and virtual memory components respectively. To interpose on functions, we remove their public-facing alias (pointing those to our own functions instead) and call the internal versions (eg __mmap64). We also added a common header included in all of our source files to /sysdeps/unix/sysv/linux/include/sys. To include our files in the build, we added the file in /misc to the routine list in /misc/Makefile, and our files in sysdeps to the sysdep_routine list in the misc section of /sysdeps/unix/sysv/linux/Makefile. We also added our header in both locations. We completely deleted /misc/munmap.c and removed its Makefile entry, and changed some filenames in /sysdeps/unix/syscalls.list to point to our own code. Other than that, the only changes we have made to existing glibc source are removing aliases for the functions we are replacing (no changes to function bodies). We are working off of the glibc-2.32 tag, building and installing as system libc inside a Ubuntu 18.04 Docker container using GCC 8 (7 is the default for 18.04) with no non-default configuration options. With that extensive preamble, the actual problem we are facing is the failure of this command: ################# cc -nostdlib -nostartfiles -r -o /glibc-wsp/build/elf/librtld.map.o -Wl,--defsym=calloc=0 -Wl,--defsym=free=0 -Wl,--defsym=malloc=0 -Wl,--defsym=realloc=0 -Wl,--defsym=__stack_chk_fail=0 -Wl,--defsym=__stack_chk_fail_local=0 \ '-Wl,-(' /glibc-wsp/build/elf/dl-allobjs.os /glibc-wsp/build/libc_pic.a -lgcc '-Wl,-)' -Wl,-Map,/glibc-wsp/build/elf/librtld.mapT /glibc-wsp/build/libc_pic.a(getcwd.os): In function `__GI___getcwd': /glibc-wsp/src/io/../sysdeps/unix/sysv/linux/getcwd.c:47: multiple definition of `__getcwd' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/../sysdeps/unix/sysv/linux/getcwd.c:47: first defined here /glibc-wsp/build/libc_pic.a(dl-error.os): In function `__GI__dl_signal_exception': /glibc-wsp/src/elf/dl-error-skeleton.c:91: multiple definition of `_dl_signal_exception' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/dl-error-skeleton.c:91: first defined here /glibc-wsp/build/libc_pic.a(dl-error.os): In function `__GI__dl_signal_error': /glibc-wsp/src/elf/dl-error-skeleton.c:109: multiple definition of `_dl_signal_error' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/dl-error-skeleton.c:109: first defined here /glibc-wsp/build/libc_pic.a(dl-error.os): In function `__GI__dl_catch_exception': /glibc-wsp/src/elf/dl-error-skeleton.c:175: multiple definition of `_dl_catch_exception' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/dl-error-skeleton.c:175: first defined here /glibc-wsp/build/libc_pic.a(dl-error.os): In function `__GI__dl_catch_error': /glibc-wsp/src/elf/dl-error-skeleton.c:225: multiple definition of `_dl_catch_error' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/dl-error-skeleton.c:225: first defined here /glibc-wsp/build/libc_pic.a(init-first.os):(.data+0x0): multiple definition of `__libc_multiple_libcs' /glibc-wsp/build/elf/dl-allobjs.os:(.bss+0xd8): first defined here /glibc-wsp/build/libc_pic.a(libc_fatal.os): In function `__GI___libc_fatal': /glibc-wsp/src/libio/../sysdeps/posix/libc_fatal.c:161: multiple definition of `__GI___libc_fatal' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/dl-minimal.c:259: first defined here /glibc-wsp/build/libc_pic.a(libc_fatal.os): In function `__GI___libc_fatal': /glibc-wsp/src/libio/../sysdeps/posix/libc_fatal.c:161: multiple definition of `__libc_fatal' /glibc-wsp/build/elf/dl-allobjs.os:/glibc-wsp/src/elf/dl-minimal.c:259: first defined here collect2: error: ld returned 1 exit status Makefile:524: recipe for target '/glibc-wsp/build/elf/librtld.map' failed ################# It seems like we're accidentally adding some symbols in either libc_pic.a or elf/dl-allobjs.os that shouldn't be there. However, I can't figure out why this is. When I compare the symbols in each object to those from an unmodified glibc build using objdump + diff, they seem to be essentially the same -- all the conflicting symbols are present in both objects in the unmodified version, from what I can see. We don't modify anything in the elf or dlfcn modules, or do anything at all to interact with any of the listed symbols as far as I can tell. What's going on here, and how can I fix it? Thanks, George P.S. More general guidance on our build scheme is also welcome if something looks wrong to you. This is my first time modifying glibc and the build system is still mostly a foreign country to me.