From owner-freebsd-hackers@freebsd.org Wed Jan 4 19:07:49 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6ED8AC9F281 for ; Wed, 4 Jan 2017 19:07:49 +0000 (UTC) (envelope-from alexander.tarasikov@gmail.com) Received: from mail-oi0-x22a.google.com (mail-oi0-x22a.google.com [IPv6:2607:f8b0:4003:c06::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3566A1311 for ; Wed, 4 Jan 2017 19:07:49 +0000 (UTC) (envelope-from alexander.tarasikov@gmail.com) Received: by mail-oi0-x22a.google.com with SMTP id v84so553458708oie.3 for ; Wed, 04 Jan 2017 11:07:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=nrD0B9yN2y5JPQ260I2beHmnOQ3lDxJ46zFZqzaswXQ=; b=VIroqTStwCkGmreWvI0hf2mp2VO3H9telZgxWniLwhDR5dEwpUwkhuDHRgHFIGV7Mc QFN5w7bmzeS2pZwsr1AhciLMR+ECK7u7UAWitw2i9rbuZ7ezxdjgMulrtfLa0D3vgMvR tnO9FoaUdBfwPnaH6Aqx8m+pS63ZwJj+rsdTNVE8TTfPm2WUc4qPDteqSPGKIdxWEIsc EQ3n1r2bmUxMr80Ab6SuUr8jKclPUPEnHhnT6PbdTN1s/FwVkMdHDfH8JRsL41X+7rJi ELMh1iMDyPhR/YjzwIcxbHm8Of2orIdiAaalr4Wkh+4VxvYCWKDwaP6nOzX8gDuuUH5e CMkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=nrD0B9yN2y5JPQ260I2beHmnOQ3lDxJ46zFZqzaswXQ=; b=L4RLrBMueaeOshmwR5nj4gh3hWa46DmsRnsLBmtFDO7zMCQHRdElwAKkmXG5SQYTKD MvziITzhsmgB+e3/OvUpBmYWT2H/mXt9I76it4KPpWZLYDUcS5FJTso8GzF4FJgJ+Cbf fHWxbXnibBPpq9Rj1PGMi+ETAe88dLuZVo1PNwrmiJAurb9C4tcpB2HrcFgpU+SKfCva EOt/zXeOLOzxlUUrQkMKPbjlgA1pgKOc25Hyb0ISllfAD69VfWhdCBhge7MVsHK3UXCI eEJOc02XQXNqnHKO3LHc2P7VaBFyP/orzn6oJHFGHMVVceXS12UgUlt2i8iTedwGmRJN QbjQ== X-Gm-Message-State: AIkVDXL83w+TuMVnSWj5d28oadMqBqurPVVJVnAFHVlBVMH1/hgSAzc9iUE5ue9RCLzCC7BXjDB4x8X0kDIpsA== X-Received: by 10.157.47.234 with SMTP id b39mr37916484otd.0.1483556867439; Wed, 04 Jan 2017 11:07:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.97.225 with HTTP; Wed, 4 Jan 2017 11:07:46 -0800 (PST) In-Reply-To: References: From: Alexander Tarasikov Date: Wed, 4 Jan 2017 22:07:46 +0300 Message-ID: Subject: Re: Using non-standard libc To: Derrick McKee Cc: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2017 19:07:49 -0000 I think you need to grep for the "environ" symbol. Most likely it's in the crt library (crt1.o or crti.o). On Linux that would be libgcc (lgcc) which provides crtbegin.o, should be something similar on FreeBSD. On Wed, Jan 4, 2017 at 9:05 PM, Derrick McKee wrote: > Hi, > > I am conducting research into memory safety, and I have developed a custom > LLVM pass. I have successfully built libc using my pass. However, when I > try to compile a helloworld program using my built libc, I get a whole > bunch of undefined reference errors: > > /path/to/custom/clang -static -nostdlib -L/usr/src/lib/libc -lc > -I/usr/src/include hello.c > > /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to > 0000000000400160 > /usr/src/lib/libc/libc.a(getenv.o): In function `__clean_env': > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x168): undefined reference to > `environ' > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x171): undefined reference to > `environ' > /usr/src/lib/libc/libc.a(getenv.o): In function `getenv': > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x1f6): undefined reference to > `environ' > /usr/src/lib/libc/libc.a(getenv.o): In function `__merge_environ': > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x42d): undefined reference to > `environ' > /usr/src/lib/libc/stdlib/getenv.c:(.text+0x459): undefined reference to > `environ' > /usr/src/lib/libc/libc.a(getenv.o):/usr/src/lib/libc/stdlib/getenv.c:(.text+0x524): > more undefined references to `environ' follow > /usr/src/lib/libc/libc.a(getprogname.o): In function `getprogname': > /usr/src/lib/libc/gen/getprogname.c:(.text+0x7): undefined reference to > `__progname' > /usr/src/lib/libc/libc.a(auxv.o): In function `init_aux_vector_once': > /usr/src/lib/libc/gen/auxv.c:(.text+0x27): undefined reference to `environ' > /usr/src/lib/libc/libc.a(exec.o): In function `execl': > /usr/src/lib/libc/gen/exec.c:(.text+0x154): undefined reference to `environ' > /usr/src/lib/libc/libc.a(exec.o): In function `execlp': > /usr/src/lib/libc/gen/exec.c:(.text+0x484): undefined reference to `environ' > /usr/src/lib/libc/libc.a(exec.o): In function `execvp': > /usr/src/lib/libc/gen/exec.c:(.text+0x4e3): undefined reference to `environ' > /usr/src/lib/libc/libc.a(exec.o): In function `execv': > /usr/src/lib/libc/gen/exec.c:(.text+0x537): undefined reference to `environ' > /usr/src/lib/libc/libc.a(exec.o):/usr/src/lib/libc/gen/exec.c:(.text+0x5b7): > more undefined references to `environ' follow > clang-4.0: error: linker command failed with exit code 1 (use -v to see > invocation) > > Any idea of what I am missing? Thanks. > -- > Derrick McKee > Ph.D. Student at Purdue University > -- > Derrick McKee > Ph.D. Student at Purdue University > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" -- Regards, Alexander