richard@aiai.ed.ac.uk (Richard Tobin) (11/02/90)
In article <781@nixbur.UUCP> jobrien@nixbur.UUCP (John O'Brien) writes: >Is there some way to change a symbol's class to "static" in a ".o" file? Almost certainly. Examine the format of symbol table entries, and see what you can do. There will be include files describing it - a.out.h perhaps, and a man page for a.out. Then write a program which reads in the .o file, and writes it out with a modified symbol table. A simple hack which may be enough is just to edit the .o file (using an editor like gnu emacs which doesn't have line length restrictions). Find the symbol name and change it to something obscure, being careful not to change its length. -- Richard -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin
srodawa@vela.acs.oakland.edu (Ron Srodawa) (11/03/90)
In article <3693@skye.ed.ac.uk> richard@aiai.UUCP (Richard Tobin) writes: >In article <781@nixbur.UUCP> jobrien@nixbur.UUCP (John O'Brien) writes: >>Is there some way to change a symbol's class to "static" in a ".o" file? > >Almost certainly. Examine the format of symbol table entries, and see what Uh? Static variables are allocated storage in a different place than non-static variables. Non-static local variables are allocated on the stack, static variables along with the text. I would expect the easiest fix is a recompile. If youy REALLY wanted to try it, you would have to increase the length of the module, note where the new space is, then change EVERY reference to the variable to the new location. This will change the address mode you will use and the new instruction may be shorter or longer than the instruction it replaces. I wouldn't even attempt to try this. Ron. -- | Ronald J. Srodawa | Internet: srodawa@unix.secs.oakland.edu | | School of Engineering and CS | UUCP: srodawa@egrunix.UUCP | | Oakland University | Voice: (313) 370-2247 | | Rochester, Michigan 48309-4401 | |
cgy@cs.brown.edu (Curtis Yarvin) (11/05/90)
In article <3653@vela.acs.oakland.edu> srodawa@vela.acs.oakland.edu (Ron Srodawa) writes: >In article <3693@skye.ed.ac.uk> richard@aiai.UUCP (Richard Tobin) writes: >>In article <781@nixbur.UUCP> jobrien@nixbur.UUCP (John O'Brien) writes: >>>Is there some way to change a symbol's class to "static" in a ".o" file? >> >>Almost certainly. Examine the format of symbol table entries, and see what > >Uh? Static variables are allocated storage in a different place than >non-static variables. Non-static local variables are allocated on the >stack, static variables along with the text. I would expect the easiest It would appear we have a terrible misunderstanding here; so, before we get an accidental flame war, let's break this thing up. There are two things you can do with the "static" keyword in C. You can tell the compiler to keep a _local_ variable in the data segment instead of the stack. Or you can prevent routines in other files from accessing a _global_ variable in a file. The first cannot be altered without a good disassembler. The second can. Which the original poster was referring to is anyone's guess; maybe he can post again & tell us. -Curtis "I tried living in the real world Instead of a shell But I was bored before I even began." - The Smiths
jobrien@nixbur.UUCP (John O'Brien) (11/06/90)
>Uh? Static variables are allocated storage in a different place than >non-static variables. Non-static local variables are allocated on the >stack, static variables along with the text. I would expect the easiest >fix is a recompile. If youy REALLY wanted to try it, you would have to >increase the length of the module, note where the new space is, then >change EVERY reference to the variable to the new location. This will >change the address mode you will use and the new instruction may be shorter >or longer than the instruction it replaces. I wouldn't even attempt to >try this. Ron. Actually I was much more concerned about the functions (which are always in the "text" section) than the variables. My question was, if I did what I was proposing to do, would symbols that been changed to static in big.o still be visible throughout "big.o", and would they be exported to the linker? I don't know COFF very well, but it seems to me that in the example I gave it seems to me that the variables "c" and "d" would be in the "bss" (uninitialized data) section whether or not they were static because they exist through out the program, and do not have initial values. I just simply want some control of which symbols are exported to the linker. John