Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
* Strange ld behavior in versions 4.0F and above
@ 2002-04-12 22:21 Fernando Nunes
  2002-04-14  5:38 ` Paul Pluzhnikov
  2002-04-16 22:33 ` Joe Mario
  0 siblings, 2 replies; 4+ messages in thread
From: Fernando Nunes @ 2002-04-12 22:21 UTC (permalink / raw)



Hi,

I'm sorry if this is a dummy question with a simple answer, but I've
RTFM and got no answers...

I've noticed a change in Tru64 4.0F "ld" behavior.
If you create a "test.c" whith the following content:
---------------------
main()
{
        foo();
}
---------------------

(and you ignore the lack of ANSI compliance in the code) and issue the
command:

cc -o test test.c

You'll get an  obviously message from the linker saying that there are
unresolved symbols.

The point is you'll have a "test" file (without execution permission)
hanging around.
This has a nasty effect if you're using the make utility because if by
mistake you repeat the make process it will skip the "test" compilation
because the file will be there (although it's completly useless).

Does this have a logical explanation? Is there any compilation/linker
flag that will avoid this? Is it some kind of bug?

Thank you in advance,

Fernando Nunes



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange ld behavior in versions 4.0F and above
  2002-04-12 22:21 Strange ld behavior in versions 4.0F and above Fernando Nunes
@ 2002-04-14  5:38 ` Paul Pluzhnikov
  2002-04-16 22:33 ` Joe Mario
  1 sibling, 0 replies; 4+ messages in thread
From: Paul Pluzhnikov @ 2002-04-14  5:38 UTC (permalink / raw)


Fernando Nunes <fernando.nunesNOSP@Mnetcabo.pt> writes:

> cc -o test test.c
> 
> You'll get an  obviously message from the linker saying that there are
> unresolved symbols.
> 
> The point is you'll have a "test" file (without execution permission)
> hanging around.
> This has a nasty effect if you're using the make utility because if by
> mistake you repeat the make process it will skip the "test" compilation
> because the file will be there (although it's completly useless).
> 
> Does this have a logical explanation? Is there any compilation/linker
> flag that will avoid this? Is it some kind of bug?

I do not know if there is an explanation for this, but I have seen
more than one system with such 'ld' behaviour ... I think Irix ld
does this as well.

Presumably 'ld' designers thought the "half-cooked" ld output
is good for something. It probably *is* good for debugging 'ld'
itself ...

The Makefile workarounds I have often encountered:

  $(EXE): $(OBJS)
        $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) || $(RM) $@

or

  $(EXE): $(OBJS)
        $(CC) $(CFLAGS) -o tmp.$@ $(OBJS) $(LIBS) && $(MV) tmp.$@ $@

Cheers,


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange ld behavior in versions 4.0F and above
  2002-04-12 22:21 Strange ld behavior in versions 4.0F and above Fernando Nunes
  2002-04-14  5:38 ` Paul Pluzhnikov
@ 2002-04-16 22:33 ` Joe Mario
  2002-04-21  0:07   ` Paul Pluzhnikov
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Mario @ 2002-04-16 22:33 UTC (permalink / raw)


Fernando Nunes wrote:
> 
> Hi,
> 
> I'm sorry if this is a dummy question with a simple answer, but I've
Fernando:
	There are many cases where users want to link their
	application with unresolved symbols so they can run
	them later with libraries that do define the 
	unresolved symbol(s).   They run "chmod +x" on the
	linked image so they can later run it.

	As another reply indicated, you can always check the
	status returned from the link if you don't want your
	makefile to proceed when unresolved symbols are 
	encountered.

Joe Mario
Compaq Tru64 UNIX Development Environment



> RTFM and got no answers...
> 
> I've noticed a change in Tru64 4.0F "ld" behavior.
> If you create a "test.c" whith the following content:
> ---------------------
> main()
> {
>         foo();
> }
> ---------------------
> 
> (and you ignore the lack of ANSI compliance in the code) and issue the
> command:
> 
> cc -o test test.c
> 
> You'll get an  obviously message from the linker saying that there are
> unresolved symbols.
> 
> The point is you'll have a "test" file (without execution permission)
> hanging around.
> This has a nasty effect if you're using the make utility because if by
> mistake you repeat the make process it will skip the "test" compilation
> because the file will be there (although it's completly useless).
> 
> Does this have a logical explanation? Is there any compilation/linker
> flag that will avoid this? Is it some kind of bug?
> 
> Thank you in advance,
> 
> Fernando Nunes


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Strange ld behavior in versions 4.0F and above
  2002-04-16 22:33 ` Joe Mario
@ 2002-04-21  0:07   ` Paul Pluzhnikov
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Pluzhnikov @ 2002-04-21  0:07 UTC (permalink / raw)


Joe Mario <mario@zk3.dec.com> writes:

> 	There are many cases where users want to link their
> 	application with unresolved symbols so they can run
> 	them later with libraries that do define the 
> 	unresolved symbol(s).   They run "chmod +x" on the
> 	linked image so they can later run it.

And their reason for not using proper libraries in the
link to begin with is?

I have never seen such a user, but I have seen the

  cc -o foo ... || rm -f foo

pattern a lot. Perhaps a better approach would have been
a special flag (e.g. --expect-unresolved), so the (rare)
user who actually needs "half-cooked" executable could
get it, while the usual user doesn't have to jump through hoops?

Cheers,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-04-21  0:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-12 22:21 Strange ld behavior in versions 4.0F and above Fernando Nunes
2002-04-14  5:38 ` Paul Pluzhnikov
2002-04-16 22:33 ` Joe Mario
2002-04-21  0:07   ` Paul Pluzhnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox