Discussion:
static link crash
(too old to reply)
nospam
2003-11-06 14:01:19 UTC
Permalink
Hello All -

When statically linking "hello world", the executable crashes at the only
link of code ( "printf(....).

I am trying to create a statically link program using the "-dn" option on
Openserver 5.0.6.

I want to avoid dynamically linking to libc.so.1. After using the "-dn"
option, there are no dependencies reported by the "ldd" utility.

I don't know the history of the Unix installation on this machine. Is
installing the static libraries a non-default option? Should I go back and
reinstall?

Any help is appreciated.

Thanks,

bruce radtke
Bela Lubkin
2003-11-06 17:37:17 UTC
Permalink
bruce radtke wrote:

> When statically linking "hello world", the executable crashes at the only
> link of code ( "printf(....).
>
> I am trying to create a statically link program using the "-dn" option on
> Openserver 5.0.6.
>
> I want to avoid dynamically linking to libc.so.1. After using the "-dn"
> option, there are no dependencies reported by the "ldd" utility.
>
> I don't know the history of the Unix installation on this machine. Is
> installing the static libraries a non-default option? Should I go back and
> reinstall?

Static libraries are installed by default.

Suppose you post the actual one line of code instead of a synopsis of
it?

>Bela<
nospam
2003-11-06 19:34:44 UTC
Permalink
Hello Bela -
The code is your basic Hello World program:

#include <stdio.h>
#include <assert.h>
int main()
{
printf( "Hello world\n");
return 0;
}
My compile flags are: -b elf -c -g
And to link: cc -dn myhello.o -o myhello

My intent is to create an executable that does not have any dynamically load
referenences ( lib.so.1).
When I try to run it crashes with a segmentation violation.
Any help would be appreciated.

Thanks.
bruce

"Bela Lubkin" <***@sco.com> wrote in message
news:***@sco.com...
> bruce radtke wrote:
>
> > When statically linking "hello world", the executable crashes at the
only
> > link of code ( "printf(....).
> >
> > I am trying to create a statically link program using the "-dn" option
on
> > Openserver 5.0.6.
> >
> > I want to avoid dynamically linking to libc.so.1. After using the
"-dn"
> > option, there are no dependencies reported by the "ldd" utility.
> >
> > I don't know the history of the Unix installation on this machine. Is
> > installing the static libraries a non-default option? Should I go back
and
> > reinstall?
>
> Static libraries are installed by default.
>
> Suppose you post the actual one line of code instead of a synopsis of
> it?
>
> >Bela<
Bela Lubkin
2003-11-06 20:25:38 UTC
Permalink
bruce radtke wrote:

> The code is your basic Hello World program:
>
> #include <stdio.h>
> #include <assert.h>
> int main()
> {
> printf( "Hello world\n");
> return 0;
> }
> My compile flags are: -b elf -c -g
> And to link: cc -dn myhello.o -o myhello
>
> My intent is to create an executable that does not have any dynamically load
> referenences ( lib.so.1).
> When I try to run it crashes with a segmentation violation.
> Any help would be appreciated.

Hmmm, well, it compiles and runs just fine for me on both OSR506 and
507. Nor do I see anything that I would expect to vary from release to
release, system to system. So, next step:

$ dbx myhello
(dbx) run
[segmentation violation]
(dbx) where

Also, if you intend to have debugging turned on in the binary, your link
line should also have "-g" in it.

>Bela<
nospam
2003-11-06 22:01:39 UTC
Permalink
Thanks for the reply, Bela. I'm a little frustrated at this moment and
appreciate your help.

When I run debug - before I do anything ( next stmt, run, etc), debug pops
up with the error message "No entry 'fork' exists'. Then the next error
is "No entry '_execve' exists" .

I select next statment to execute the printf command. A popup error
displays "Top stack frame invalid, program counter out of range". Hit OK.
Next error message "Stack adjusted to start with previous frame". I hit OK.
I hit next stmt - error message "Invalid text address 0x240000ff".

I suspect that I'm linking to some libc.a file that is not for this system -
OpenServer 5.0.6. I'm clueless. other then reinstalling Unix again I'm
not sure what to do.


"Bela Lubkin" <***@sco.com> wrote in message
news:***@sco.com...
> bruce radtke wrote:
>
> > The code is your basic Hello World program:
> >
> > #include <stdio.h>
> > #include <assert.h>
> > int main()
> > {
> > printf( "Hello world\n");
> > return 0;
> > }
> > My compile flags are: -b elf -c -g
> > And to link: cc -dn myhello.o -o myhello
> >
> > My intent is to create an executable that does not have any dynamically
load
> > referenences ( lib.so.1).
> > When I try to run it crashes with a segmentation violation.
> > Any help would be appreciated.
>
> Hmmm, well, it compiles and runs just fine for me on both OSR506 and
> 507. Nor do I see anything that I would expect to vary from release to
> release, system to system. So, next step:
>
> $ dbx myhello
> (dbx) run
> [segmentation violation]
> (dbx) where
>
> Also, if you intend to have debugging turned on in the binary, your link
> line should also have "-g" in it.
>
> >Bela<
Bela Lubkin
2003-11-06 23:34:01 UTC
Permalink
bruce radtke wrote:

> When I run debug - before I do anything ( next stmt, run, etc), debug pops
> up with the error message "No entry 'fork' exists'. Then the next error
> is "No entry '_execve' exists" .

I just tried that and got the same results. Your description makes it
sound like you were using the X11 interface to `debug`; I was using the
ASCII interface. The entire session looked like:

$ /udk/usr/ccs/bin/debug myhello
Warning: No entry "_fork" exists
Warning: No entry "_execve" exists
New program myhello (process p1) created
HALTED p1 [.text in myhello.c]
5: printf( "Hello world\n");
debug> run
Hello world
Process p1 has exited
No more processes
debug> q

So those messages were printed, but made no difference; debug was still
able to run the program.

> I select next statment to execute the printf command. A popup error
> displays "Top stack frame invalid, program counter out of range". Hit OK.
> Next error message "Stack adjusted to start with previous frame". I hit OK.
> I hit next stmt - error message "Invalid text address 0x240000ff".
>
> I suspect that I'm linking to some libc.a file that is not for this system -
> OpenServer 5.0.6. I'm clueless. other then reinstalling Unix again I'm
> not sure what to do.

I think you've inadvertently given me a big clue. I said to use `dbx`.
You used `debug`. That's part of the UDK (UnixWare/OpenServer Developer
Kit), which is not the native development system for OpenServer. Sure
enough, if I compile myhello.c to a static ELF binary using the UDK, the
resulting binary dumps core. Which is expected: the UDK's ability to
generate binaries that run on both OpenServer and UnixWare relies on
shared library trickery.

You're using the wrong development system for the task. UDK-generated
static binaries run only on UnixWare.

UDK is on a separate CD that comes with the OpenServer media
distribution. The OpenServer Development System is on the main OSR5 CD.
It is a licensed $$ product. If you have a license for it, install it
(run `scoadmin software`, point it at the CD, install "SCO OpenServer
Development System"). If you don't have a license, buy one; or install
"SCO OpenServer Linker and Application Development Libraries", which is
free, then install an appropriate gcc distribution (someone else will
have to help you with specific URLs for that).

>Bela<
nospam
2003-11-07 13:26:44 UTC
Permalink
Thanks Bela. That fixed my static link problem.

"Bela Lubkin" <***@sco.com> wrote in message
news:***@sco.com...
> bruce radtke wrote:
>
> > When I run debug - before I do anything ( next stmt, run, etc), debug
pops
> > up with the error message "No entry 'fork' exists'. Then the next
error
> > is "No entry '_execve' exists" .
>
> I just tried that and got the same results. Your description makes it
> sound like you were using the X11 interface to `debug`; I was using the
> ASCII interface. The entire session looked like:
>
> $ /udk/usr/ccs/bin/debug myhello
> Warning: No entry "_fork" exists
> Warning: No entry "_execve" exists
> New program myhello (process p1) created
> HALTED p1 [.text in myhello.c]
> 5: printf( "Hello world\n");
> debug> run
> Hello world
> Process p1 has exited
> No more processes
> debug> q
>
> So those messages were printed, but made no difference; debug was still
> able to run the program.
>
> > I select next statment to execute the printf command. A popup error
> > displays "Top stack frame invalid, program counter out of range". Hit
OK.
> > Next error message "Stack adjusted to start with previous frame". I hit
OK.
> > I hit next stmt - error message "Invalid text address 0x240000ff".
> >
> > I suspect that I'm linking to some libc.a file that is not for this
system -
> > OpenServer 5.0.6. I'm clueless. other then reinstalling Unix again
I'm
> > not sure what to do.
>
> I think you've inadvertently given me a big clue. I said to use `dbx`.
> You used `debug`. That's part of the UDK (UnixWare/OpenServer Developer
> Kit), which is not the native development system for OpenServer. Sure
> enough, if I compile myhello.c to a static ELF binary using the UDK, the
> resulting binary dumps core. Which is expected: the UDK's ability to
> generate binaries that run on both OpenServer and UnixWare relies on
> shared library trickery.
>
> You're using the wrong development system for the task. UDK-generated
> static binaries run only on UnixWare.
>
> UDK is on a separate CD that comes with the OpenServer media
> distribution. The OpenServer Development System is on the main OSR5 CD.
> It is a licensed $$ product. If you have a license for it, install it
> (run `scoadmin software`, point it at the CD, install "SCO OpenServer
> Development System"). If you don't have a license, buy one; or install
> "SCO OpenServer Linker and Application Development Libraries", which is
> free, then install an appropriate gcc distribution (someone else will
> have to help you with specific URLs for that).
>
> >Bela<
Tony Lawrence
2003-11-09 15:10:50 UTC
Permalink
Bela Lubkin <***@sco.com> wrote:
>bruce radtke wrote:

>> When I run debug - before I do anything ( next stmt, run, etc), debug pops
>> up with the error message "No entry 'fork' exists'. Then the next error
>> is "No entry '_execve' exists" .

>I just tried that and got the same results. Your description makes it
>sound like you were using the X11 interface to `debug`; I was using the
>ASCII interface. The entire session looked like:

> $ /udk/usr/ccs/bin/debug myhello
> Warning: No entry "_fork" exists
> Warning: No entry "_execve" exists
> New program myhello (process p1) created
> HALTED p1 [.text in myhello.c]
> 5: printf( "Hello world\n");
> debug> run
> Hello world
> Process p1 has exited
> No more processes
> debug> q

>So those messages were printed, but made no difference; debug was still
>able to run the program.

>> I select next statment to execute the printf command. A popup error
>> displays "Top stack frame invalid, program counter out of range". Hit OK.
>> Next error message "Stack adjusted to start with previous frame". I hit OK.
>> I hit next stmt - error message "Invalid text address 0x240000ff".
>>
>> I suspect that I'm linking to some libc.a file that is not for this system -
>> OpenServer 5.0.6. I'm clueless. other then reinstalling Unix again I'm
>> not sure what to do.

>I think you've inadvertently given me a big clue. I said to use `dbx`.
>You used `debug`. That's part of the UDK (UnixWare/OpenServer Developer
>Kit), which is not the native development system for OpenServer. Sure
>enough, if I compile myhello.c to a static ELF binary using the UDK, the
>resulting binary dumps core. Which is expected: the UDK's ability to
>generate binaries that run on both OpenServer and UnixWare relies on
>shared library trickery.

>You're using the wrong development system for the task. UDK-generated
>static binaries run only on UnixWare.

>UDK is on a separate CD that comes with the OpenServer media
>distribution. The OpenServer Development System is on the main OSR5 CD.
>It is a licensed $$ product. If you have a license for it, install it
>(run `scoadmin software`, point it at the CD, install "SCO OpenServer
>Development System"). If you don't have a license, buy one; or install
>"SCO OpenServer Linker and Application Development Libraries", which is
>free, then install an appropriate gcc distribution (someone else will
>have to help you with specific URLs for that).

Well, on 5.0.7 it's right on the OS CD.

Prior to that, it's still out at http://www.sco.com/skunkware , isn't
it?

--
***@aplawrence.com Unix/Linux/Mac OS X resources: http://aplawrence.com
Get paid for writing about tech: http://aplawrence.com/publish.html
Bela Lubkin
2003-11-09 20:30:36 UTC
Permalink
Tony Lawrence wrote:

> Bela Lubkin <***@sco.com> wrote:

> If you don't have a license, buy one; or install
> >"SCO OpenServer Linker and Application Development Libraries", which is
> >free, then install an appropriate gcc distribution (someone else will
> >have to help you with specific URLs for that).
>
> Well, on 5.0.7 it's right on the OS CD.
>
> Prior to that, it's still out at http://www.sco.com/skunkware , isn't
> it?

Some version is, yes. Then there's the version at:

ftp://ftp.sco.com/pub/openserver5/opensrc/

(gnutools contains gcc). I find the Skunkware repository confusing and
hard to navigate; and the gnutools version is newer and probably better
integrated. But its README says it's only supported on OSR507 (but has
been observed to work on releases back to 504).

I can't give good advice about which stuff to use because I've never
installed those pieces. In the past I didn't install gcc on my
machines; now I install whatever version of gnutools comes with the OS,
and apply the updates, but I'm applying them onto their intended OS
(507) and don't have any idea how they behave on older releases.

>Bela<
Loading...