Operating System - HP-UX
1753612 Members
6018 Online
108797 Solutions
New Discussion юеВ

Adding tags in Executable

 
SOLVED
Go to solution
Vibhor Kumar Agarwal
Esteemed Contributor

Adding tags in Executable

Sorry I had to start a new thread as that magical answer sign was creating a problem.

Okay so finally getting the feeling that there is nothing in HP like mcs.

But still I have to try and finally came upto something after so many days.
Some help needed for this.

ld has some options which may be useful for me:
+h file_name
It says it gives an internal name to the generated shared lib. Now what is this internal name?

It also states something about mapfile. I unable to figure out what is the use of mapfile.

I have a 2 step compilation process
First:
aCC -c flags ( produces .o )
Second:
aCC objs flags -o file

Now how can i add my +h option here.
I am passing flags to the linker using "flags" -> -Wl,+s,-a,default
Here i am trying to pass +h name but it gives me error.
I also tried -c file ( in which i had given the +h), it doesn't work either.

Please help
Vibhor Kumar Agarwal
10 REPLIES 10
Ermin Borovac
Honored Contributor

Re: Adding tags in Executable

FWIW command called 'what' will print out identification information about executable or library if source file(s) used to compile contain the following line.

char ident[] = "@(#)identification information";

$ what a.out
a.out: identification information
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Adding tags in Executable

This is what i exactly want to do, and what i had being doing in Solaris.

But for that i didn't had to touch the source code in solaris.

I used mcs.
I read the man pages of aCC and came up with some options that could help me to achieve that thing.
I am just unable to put it together.
Vibhor Kumar Agarwal
Stephen Keane
Honored Contributor

Re: Adding tags in Executable

mcs adjusts the .comment field in an ELF executable. So I guess the first thing you have to ensure is that you are creating an ELF executable and not a PA-RISC one, then we'd have to find somthing that lets you change the .comment field.
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Adding tags in Executable

On doing file operation on my .sl, I am getting

ELF-64 shared object file - PA-RISC 2.0 (LP64)

What is this, it contains both ELF and PA_RISC.

I know ELF but nothing about the latter one.
Going to google.
Vibhor Kumar Agarwal
Stephen Keane
Honored Contributor

Re: Adding tags in Executable

That's OK, what you didn't want to see was

PA-RISC1.1 shared executable
or something similar without the ELF part.
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Adding tags in Executable

Okay,

So now help me to solve it.

Vibhor Kumar Agarwal
Stephen Keane
Honored Contributor
Solution

Re: Adding tags in Executable

Probably the only way you're going to get anywhere near what you want is to

(a) create a file called say ident.c
and place in it the identification string as suggested by ermin.

(b) semi-compile that ident.c file into an ident.o file (once)

(c) semi-compile your code as normal to .o stage.

(d) When linking, include the ident.o file in the link line.

Use 'what' on your executable to get the ident info.

This sort of meets your requirements as you have made no changes to your code, you are merely relinking it. If you want a different ident in each executable, as opposed to a project wide ident that effectively is a version number, then you'd have to create multiple ident.o file. When you change the ident, you just relink, you don't have to recompile your code.

Vibhor Kumar Agarwal
Esteemed Contributor

Re: Adding tags in Executable

So,

Finally something to work on.
Good option!

I was thinking something else.
I was searching about that internal name which i mentioned in my first post.

Till now i am unable to find out what is it.
If it somehow gives an name to the executable then we can use that option also.

Can you help me in this case.
Thanks
Vibhor Kumar Agarwal
Stephen Keane
Honored Contributor

Re: Adding tags in Executable

They way I understood it, the +h flag gives a shared library an internal name, and thus wouldn't be of any use in your case for use in an executable.