*BSD News Article 83906


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.cs.su.oz.au!metro!metro!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!EU.net!main.Germany.EU.net!Duesseldorf.Germany.EU.net!Bonn.Germany.EU.net!tools!usenet
From: jk@tools.de (Juergen Keil)
Newsgroups: comp.unix.solaris,comp.unix.bsd.misc
Subject: Re: Solaris 2.6
Date: 29 Nov 1996 14:25:51 GMT
Organization: TooLs GmbH, Bonn, Germany
Lines: 116
Distribution: inet
Message-ID: <JK.96Nov29152551@leo.tools.de>
References: <32986299.AC7@mail.esrin.esa.it> <57djlg$bks@agate.berkeley.edu>
	<57dkbq$bsr@panix2.panix.com> <casper.329abb76@mail.fwi.uva.nl>
	<57ej3a$7ij@panix2.panix.com> <casper.329ae8f2@mail.fwi.uva.nl>
	<57hhcp$kp9@innocence.interface-business.de>
NNTP-Posting-Host: leo.tools.de
In-reply-to: j@ida.interface-business.de's message of 27 Nov 1996 13:57:45 GMT
Xref: euryale.cc.adfa.oz.au comp.unix.solaris:90938 comp.unix.bsd.misc:1631

In article <57hhcp$kp9@innocence.interface-business.de> j@ida.interface-business.de (J Wunsch) writes:

> It's funny that you're arguing a hypothetical case, while people
> who've been gone through all this already tell you _that it simply
> works for us_, ain't it?
> 
> Anyway:
> 
> j@ida 608% cat foo.c
> #include <unistd.h>
> #include <fcntl.h>

... bogus example deleted ...


Here's a small modification for your program (the _startup_setlocale
is for FreeBSD 2.0's crt0 which references a libc routine that is not
present in the older libc.so.1.1):

1% diff -c foo-orig.c foo.c
*** foo-orig.c	Fri Nov 29 14:21:22 1996
--- foo.c	Fri Nov 29 14:12:59 1996
***************
*** 14,22 ****
          if ((fd = open("foobar", O_RDWR|O_CREAT, 0666)) == -1)
                  return 1;
          write(fd, s, sizeof s - 1);
!         lseek(fd, 6, SEEK_SET);
          x = read(fd, b, 200);
          write(1, b, x);
  
          return 0;
  }
--- 14,24 ----
          if ((fd = open("foobar", O_RDWR|O_CREAT, 0666)) == -1)
                  return 1;
          write(fd, s, sizeof s - 1);
!         lseek(fd, -7, SEEK_END);
          x = read(fd, b, 200);
          write(1, b, x);
  
          return 0;
  }
+ 
+ _startup_setlocale(){}



2% cat foo.c
#include <unistd.h>
#include <fcntl.h>

char s[] = "Hello\nworld!\n";

int
main(void)
{
        int fd;
        off_t o;
        ssize_t x;
        char b[200];

        if ((fd = open("foobar", O_RDWR|O_CREAT, 0666)) == -1)
                return 1;
        write(fd, s, sizeof s - 1);
        lseek(fd, -7, SEEK_END);
        x = read(fd, b, 200);
        write(1, b, x);

        return 0;
}

_startup_setlocale(){}
3% cc -c foo.c
4% ld -e start -dc -dp -o foo /usr/lib/crt0.o foo.o -lc /usr/lib/libgcc.a
5% ldd foo
foo:
	-lc.2 => /usr/lib/libc.so.2.0 (0x1001a000)
6% rm foobar
7% ./foo
world!
8% ld -e start -dc -dp -o foo /usr/lib/crt0.o foo.o /usr/lib/libc.so.1.1  /usr/lib/libgcc.a
9% ldd foo
foo:
	/usr/lib/libc.so.1.1 => /usr/lib/libc.so.1.1 (0x10019000)
10% rm foobar
11% ./foo
12% ktrace ./foo
13% kdump | tail -20
 12833 foo      CALL  open
 12833 foo      NAMI  "foobar"
 12833 foo      RET   open 3
 12833 foo      CALL  write
 12833 foo      GIO   fd 3 wrote 13 bytes
       "Hello
	world!
       "
 12833 foo      RET   write 13/0xd
 12833 foo      CALL  old.lseek
 12833 foo      RET   old.lseek -1 errno 22 Invalid argument
 12833 foo      CALL  read
 12833 foo      GIO   fd 3 read 0 bytes
       ""
 12833 foo      RET   read 0
 12833 foo      CALL  write
 12833 foo      GIO   fd 1 wrote 0 bytes
       ""
 12833 foo      RET   write 0
 12833 foo      CALL  exit
14%

> With either the new or the old shared lib, it works.

Your code example worked only by chance.
-- 
Juergen Keil          jk@tools.de ...!{uunet,mcsun}!unido!tools!jk