From owner-freebsd-questions@freebsd.org Wed Jan 4 15:52:07 2017 Return-Path: Delivered-To: freebsd-questions@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 845ECC9FB92 for ; Wed, 4 Jan 2017 15:52:07 +0000 (UTC) (envelope-from derrick.mckee@gmail.com) Received: from mail-ua0-x235.google.com (mail-ua0-x235.google.com [IPv6:2607:f8b0:400c:c08::235]) (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 4122315D8 for ; Wed, 4 Jan 2017 15:52:07 +0000 (UTC) (envelope-from derrick.mckee@gmail.com) Received: by mail-ua0-x235.google.com with SMTP id 88so347993874uaq.3 for ; Wed, 04 Jan 2017 07:52:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=q6260tmVJUS14PZGSgKZpshUzs3uZhZWC4ZldJ+LVmY=; b=elbxnRFKMntILBQ+DN7Zie4YWu/njPNTsX5pSZ8ByDtAduYXmxaFNt+zWTjBKl535b RXsKvgLwKG7K6beWTFWkrMSlDpWhkPMwNRo8WuRnQm8K+/mR7EDPME1eWkR2AdHYp78w ONtayWCnuLhykuFgwZ/vgngCx54Vupx9Ks5J1jgCeUOQ0O90V1a4UseYyzpCglymlrIP CGLvi2mJO34tWokrGsbBNYnn+8/GvqBEZFS48+Y3gpG/hgd2D8UdgYmqhHQQ/CiInJN7 R/3A2sVkMB2Wgt0cGZ+k8AmcDwqJALbsBKCQWPksuN6wZ199GCVa8a2vb+MT0UM7LtqJ FxtQ== 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=q6260tmVJUS14PZGSgKZpshUzs3uZhZWC4ZldJ+LVmY=; b=ms3e1OQHoR5c/HFOsk7NoHXqx3sEqOo7Tm9Xn3m4KcyQx8dwbEnxRXchyUDbD2lj0F BTE+wBkv7VSjtvpcPJ2SoMM/m3kfG1In4EMNZe+9VWIv9YG2thQ3m9NBedFmP6I8Uuj2 pbjsoqAFQf+/pUvEAWdI8wosjt1eH2/TfqJdDxTj1aDz8vnfIiTt6Ms6LEJqmnqIVFPc WV/QrYCCJlrgLXW04hKkw5hDvp+OCBEDrUa6j6mafELUGl3Cr1TB5K4AtBpAXjVebp8g xm665rREGWpxVz6bAuGGDRwtkuo8dgXC1lFQ2/YjcfhXX8+/9DwnepOl0Hcp+b3sLi0C FuAA== X-Gm-Message-State: AIkVDXINc8qvi0YhSw6M8cvNHy608WKpDUF3H8ydUguHHl0BC6U1FjZIY6flVq41vlxOGJ1t43AOoP3lNS0GIQ== X-Received: by 10.159.36.108 with SMTP id 99mr42583386uaq.27.1483545126106; Wed, 04 Jan 2017 07:52:06 -0800 (PST) MIME-Version: 1.0 From: Derrick McKee Date: Wed, 04 Jan 2017 15:51:55 +0000 Message-ID: Subject: Using non-standard libc To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2017 15:52:07 -0000 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 what I am missing? Thanks. -- Derrick McKee Ph.D. Student at Purdue University