in reply to Re: Source files going into perl interpreter during compilation
in thread Source files going into perl interpreter during compilation

^^Thanks a lot. That was really good.

So, I tried working with .o files and used "strings" on all of those. Basically, what I have done is inserted the following right at the bottom of each .c and .h file.

static char *a = "Filename";

But because it is defined as static, those strings don't show up using strings command (in .so as well as the executable). Why? I do not know myself. It works when I do that for dummy files.

When I remove the static keyword,there are linker issues showing redefinitions all over the place.

#warnings was an interesting idea and I tried it out just now. It's successful in the sense that it does print out the warnings along with all the other compiler messages.

But, I cannot make it output to a file so I can analyze it. No, redirection ( make > makelog.txt) is not working.

This is getting really interesting. Any further help will be greatly appreciated.

Thanks
  • Comment on Re^2: Source files going into perl interpreter during compilation

Replies are listed 'Best First'.
Re^3: Source files going into perl interpreter during compilation
by BrowserUk (Patriarch) on Jun 21, 2011 at 23:04 UTC
    But because it is defined as static, those strings don't show up using strings command (in .so as well as the executable). Why? I do not know myself. It works when I do that for dummy files.

    Perhaps because Perl compiles with optimisation turned on, and unless those strings where referenced somewhere, they'll just be omptimised away.

    But, I cannot make it output to a file so I can analyze it. No, redirection ( make > makelog.txt) is not working.

    Have you tried make 2>&1 > make.log?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Have you tried make 2>&1 > make.log?
      At least in bash, the redirections must be switched (as shown in bash):
      make > make.log 2>&1

        This is perfect...switched redirections do work. I wasn't aware of this at all.

        Now, I have got all the #warning messages in a log file, sizeof(logfile)=19000+ lines. I can easily parse it using perl itself. A hackneyed and definitely not elegant approach, but definitely seems to work.

        Thanks a lot monks. If there is any other solution that one can think of, it'll be great for the sake of sharing knowledge

        UPDATE: Also, like BrowserUK said, it is using -O2 optimization and hence static char* are not being displayed using "strings" in any .o file. But simple char* are displayed. This still seems confusing to me. I guess I might have to read up a bit on compiler optimizations.