The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: pino@dohd.org (Martijn van Buul)
Subject: [pups] Stupid question..
Date: Mon, 15 Jan 2001 15:53:15 +0100	[thread overview]
Message-ID: <20010115155315.A16975@mud.stack.nl> (raw)

Hey.

I'm playing around with a /53 running 2.11BSD, trying to port some 
software, and I have a (probably stupid) problem: environ.

When I write a simple program like

#include <stdio.h>

extern char **environ;

void main(argc, argv)
int argc;
char **argv;
{
    printf("Hello world!");
    environ=environ;
}

and compile & link it using cc ("cc -o test test.c"), things go fine, 
however if I link things manually ("cc -c test.c ; ld -o test test.o -lc")
I get an unresolved _environ. By some experimentation, I noticed that
including /lib/crt0.o in the linker helps to some extent - however,
the binary generated by cc works like a charm, while the manually
linked version quits with a bus error. Any ideas?




-- 
    Martijn van Buul -  Pino at dohd.org - http://www.stack.nl/~martijnb/
	 Geek code: G--  - Visit OuterSpace: mud.stack.nl 3333
   Kees J. Bot: The sum of CPU power and user brain power is a constant.

Received: (from major at localhost)
	by minnie.cs.adfa.edu.au (8.9.3/8.9.3) id JAA08435
	for pups-liszt; Tue, 16 Jan 2001 09:22:57 +1100 (EST)
	(envelope-from owner-pups at minnie.cs.adfa.edu.au)
Received: from henry.cs.adfa.edu.au (henry.cs.adfa.edu.au [131.236.21.158])
	by minnie.cs.adfa.edu.au (8.9.3/8.9.3) with ESMTP id JAA08430
	for <pups at minnie.cs.adfa.edu.au>; Tue, 16 Jan 2001 09:22:55 +1100 (EST)
	(envelope-from wkt at henry.cs.adfa.edu.au)
Received: (from wkt at localhost)
	by henry.cs.adfa.edu.au (8.11.1/8.9.3) id f0FMTm309828
	for pups at minnie.cs.adfa.edu.au; Tue, 16 Jan 2001 09:29:48 +1100 (EST)
	(envelope-from wkt)
Received: from moe.2bsd.com (MOE.2BSD.COM [206.139.202.200])
	by minnie.cs.adfa.edu.au (8.9.3/8.9.3) with ESMTP id JAA08355
	for <pups at minnie.cs.adfa.edu.au>; Tue, 16 Jan 2001 09:17:00 +1100 (EST)
	(envelope-from sms at moe.2bsd.com)
Received: (from sms at localhost)
	by moe.2bsd.com (8.10.1/8.10.1) id f0FMFjJ26746
	for pups at minnie.cs.adfa.edu.au; Mon, 15 Jan 2001 14:15:45 -0800 (PST)
Date: Mon, 15 Jan 2001 14:15:45 -0800 (PST)
From: "Steven M. Schultz" <sms@moe.2bsd.com>
Message-Id: <200101152215.f0FMFjJ26746 at moe.2bsd.com>
To: pups at minnie.cs.adfa.edu.au
Subject: Re: [pups] Stupid question..
Sender: owner-pups at minnie.cs.adfa.edu.au
Precedence: bulk

Hi -

> From: Martijn van Buul <pino at dohd.org>
> 
> however if I link things manually ("cc -c test.c ; ld -o test test.o -lc")
> I get an unresolved _environ. By some experimentation, I noticed that
> including /lib/crt0.o in the linker helps to some extent - however,
> the binary generated by cc works like a charm, while the manually
> linked version quits with a bus error. Any ideas?

	Try placing /lib/crt0.o before the test.o:

		ld -o test /lib/crt0.o test.o -lc

	on another note it's usually not a good idea to call a program 'test'
	because when you are least expecting it you will end up running
	/bin/test and wonder what is wrong.

	Steven



                 reply	other threads:[~2001-01-15 14:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010115155315.A16975@mud.stack.nl \
    --to=pino@dohd.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).