2.11bsd rogue can't build

Warner Losh imp at bsdimp.com
Sat Mar 7 09:00:35 CST 2020

On Fri, Mar 6, 2020 at 10:25 PM Jacob Ritorto via cctalk <
cctalk at classiccmp.org> wrote:

> Thanks for the leads, everyone!
> I made a little progress: I did read enough about ld to get it to load
> the .o files from the initial cc run into a separate I&d overlaid
> executable.  But when I execute it, it gives me Segmentation fault
> (core dumped).. There was one complaint of Undefined during the ld run
> even though I said -lc_p (and validated that _environ is in that .a
> file using nm.
> Undefined:
> _environ
> but it seemed to succeed in building the executable despite that.
> Well, I'm guessing it succeeded because the output file rogue is
> sitting there afterwards and has been marked executable, which,
> according to the man page, ld doesn't mark that way unless it
> succeeds.
> [35] root--> ld -t -v -M -i -X -x init.o main.o level.o score.o
> machdep.o inventory.o -Z hit.o monster.o -Z message.o move.o -Z
> object.o pack.o play.o -Z curses.o random.o ring.o -Z room.o -Z save.o
> spec_hit.o -Z throw.o trap.o -Z use.o zap.o -Y -o rogue -lcurses
> -ltermlib -lc_p
> [36] root--> size rogue
> text    data    bss     dec     hex
> 44928   18554   10520   74002   12112   total text: 88704
>         overlays: 7616,6144,7488,1856,4352,6144,3840,6336
> [37] root--> ./rogue
> Segmentation fault (core dumped)
> See anything amiss in my process?  That Undefined _environ during ld
> still bugs me.
> Is the next step dissecting the program or its core with adb to find
> what's wrong?

You should check to see if crt saves the third argument to start/main.
That's what environ is. But you'll need to look at the code.

src/lib/libc/gen/getenv expects environ to be a global variable:

	extern char	**environ;

and if getenv is called, that may be where that comes from. It's defined in
pdp/csu/crt0.s:_environ: .=.+2 /   others
where it also looks to be set. Is crt0.o not getting pulled in for some


More information about the cctalk mailing list