From owner-freebsd-hackers@freebsd.org Wed Jan 4 18:05:16 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 75C19C9F355 for ; Wed, 4 Jan 2017 18:05:16 +0000 (UTC) (envelope-from derrick.mckee@gmail.com) Received: from mail-vk0-x22e.google.com (mail-vk0-x22e.google.com [IPv6:2607:f8b0:400c:c05::22e]) (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 307731EDF for ; Wed, 4 Jan 2017 18:05:16 +0000 (UTC) (envelope-from derrick.mckee@gmail.com) Received: by mail-vk0-x22e.google.com with SMTP id 137so290669592vkl.0 for ; Wed, 04 Jan 2017 10:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=NjZWr0/woneWrJkAmhIqbIuK7M6aDlPmOpM/7d9bf9I=; b=DtXZGA/BIe4QBbn2J+8LktZjxPPjdsI9anVvOXjixsi1DFYb70W9iJOw0mEpRxs5mw CcUPFIMI59xljdt9slGryZBXhFuMMTJSzcPsKS5m9dJtHsER2dZoO3DBUncfeR0WVjsl CxwfbQIerZ9f26I0j2O/oZ5rb0Uz19clr3G2WHkBPES2DoDsZAm+VsBYkJdOz+HF5ZBO 202gsZNoWNSI9isEMNBSdpYsWI7IIP23dfu3HpMEVaaqElFIHrBG2g155aPq/NagUkrq gtKzKX1Qky2SAWBdu28TLfCE/Vm5dN/zZbM/15rCrrqhVbEJVj/JSALIH48DV7xzg4uz Uddg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=NjZWr0/woneWrJkAmhIqbIuK7M6aDlPmOpM/7d9bf9I=; b=cCP7neKcjZtNG3JIZPg7LZYx/gYZPxZxaqnKygXYEFtpmfatYbJE5jfy82uxMLNqAu apYG5uB6olRymIdIoLm8vObwe3gJIaBynzZ6PO+psmMwX03BbIH3Cm/3n/MfIhjervp3 21CVxrLbCWxm96YuGMGsVtaBzziBaynlHgIhusX2Pq17wghMct7TzH95FeXu4boWupLe q2mYNj999HXEKSOciCke7xViy7D68J5q1VAHi7j3gI3SAxwabpaCTL6K2DZwHcNHppyB M1hrvLAAqYZLCqCA0NDYa8hY8cq8wQIBHkvLc3zG0II9tbPIqoTUhPu4Ezy//vcOFqnK U4hg== X-Gm-Message-State: AIkVDXIP8kHxI+w/hKu1Pd8gKEGczUguE5L3K6mypuHATL6QoWuGQYOpkc7Mmk6l9hsET1ffLxL1Iu3h37z7Xw== X-Received: by 10.31.227.130 with SMTP id a124mr19302953vkh.45.1483553113742; Wed, 04 Jan 2017 10:05:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Derrick McKee Date: Wed, 04 Jan 2017 18:05:03 +0000 Message-ID: Subject: Using non-standard libc To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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 18:05:16 -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 of what I am missing? Thanks. -- Derrick McKee Ph.D. Student at Purdue University -- Derrick McKee Ph.D. Student at Purdue University