This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Printable information in executables

> From: Alex Vinokur
> Sent: Monday, November 03, 2003 6:05 AM

> Executable files contain various printable information.
> For instance, list of  used DLLs.
> However those files contain neither compiler name nor compiler version.
> It seems to be worth including something like "gcc version 3.3.1
> (cygming special)" in executables.
> Next question. Is it possible to add 'user related printable
> information' to executables (through compilation option or something
> else)?

 The answer depends on how you plan to use that information.

The simplest form is just to declare a static string (char array), making
sure that the compiler doesn't remove it at optimization. (Hmm...? Is it
enough to do some dummy reference to it?)

This gives a simplified image of the true heuristics but anyway;
on the old AmigaOS they use(d) something like:

$ cat chk.c
int main() {
  char versionstring[]="$VER: name major.minor (date) extended_info";
  return 0;

$ for (( n=0; n<4; n++ )) do
  gcc -O$n chk.c;
  echo -n $n:;
  strings a.exe | grep '$VER: ';
0:$VER: name major.minor (date) extended_info
1:$VER: name major.minor (date) extended_info
2:$VER: name major.minor (date) extended_info
3:$VER: name major.minor (date) extended_info

Hmm... :-} it doesn't get removed by plain optimization... :-)

/Hannu E K Nevalainen, B.Sc. EE - 59?16.37'N, 17?12.60'E
-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]