1833758 Members
3613 Online
110063 Solutions
New Discussion

ld and -y option

 
SOLVED
Go to solution
Stephen Badgett
Regular Advisor

ld and -y option

ld and -y

In the HP-DOCS "-y symbol Indicate each file in which symbol appears. More than one symbol can be specified, but each must be preceded by -y."

"Indicate each file" <-- what does this mean? Do I put the "symbol" here or the file name? I would like to have more of a description of what the "-y" option does.


Thank you,
Steve
Not as is, is now
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: ld and -y option

You are making this harder than it is. I suppose that it would make more sense if the man page read "PRINT each file" rather than "INDICATE" each file. The idea is that the linker tells you (rather than the other way around) every file in which the symbol is found. For example, if the function "Mickey" and the variable "Mouse" were referenced/defined in several files, -y will tell you where each instance of the symbol is found.

ld -y Mickey -y Mouse file1.o file2.o file3.o .... libraries

might do something like this:
file1.o: Mickey is ENTRY UNIVERSAL
file3.o: Mouse is DATA UNIVERSAL

"indicating" that Mickey is found in file1.o and Mouse is found in file3.o.

More commonly it's passed in to the linker from the compiler so it would be done like this:

cc -Wl,-y Mickey -Wl,-y Mouse -o file file1.c file2.o file3.o

In some implementations, you actually need to prepend each symbol with an underscore but that is not necessary under HP-UX.
If it ain't broke, I can fix that.
Laurent Menase
Honored Contributor

Re: ld and -y option

Hi Steve,
# cc -c t.c
# cc -c x.c
# ld -y toto -y yoyo t.o x.o -r
t.o: yoyo is DATA UNIVERSAL
t.o: toto is CODE UNSAT
x.o: toto is ENTRY UNIVERSAL
# cat t.c
int yoyo=1;

main()
{
toto();
}
# cat x.c
toto()
{
}
Stephen Badgett
Regular Advisor

Re: ld and -y option

thank you
Not as is, is now