This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: RFA: Add -frecord-gcc-switches command line switch


Hi Mark,

I see one more thing that I want to clarify before approving the patch:

+	    fputs ("\t.ascii \"", asm_out_file);
+
+	  varasm_print_gcc_option (name);
+	  fputs ("\\0\"\n", asm_out_file);

Can we use ASM_OUTPUT_ASCII here instead?

Well yes, but it is a bit of a pain. (Lots of copying of strings into buffers so that they can be combined later on).


It looks like that might
handle the escaping, quoting, embedded NUL issues that you're dealing
with here, and make elf_record_gcc_switches work on any ELF platforms
that use something other than .ascii for strings.  It looks to me like
something like this:

ASM_OUTPUT_ASCII (asm_out_file, name, strlen (name) + 1);

would work. (The +1 is so that we encode the trailing NUL.)

Which unfortunately does not work. The NULs are still skipped by the implementation of ASM_OUTPUT_ASCII in config/elfos.h. (It treats them as sub-string terminators and breaks up the output into multiple strings).


A revised patch, using ASM_OUTPUT_ASCII and ASM_OUTPUT_SKIP (to generate the NULs) is attached. I decided to ditch the code that specially handles double quote characters inside command line options, since this is a very rare occurrence, and it would mean that I would have to write my own customized implementation of snprintf. I can put this back in though, if you feel that it is important.

How to do you feel about this version ?

Cheers
  Nick

PS. In case anyone is wondering the NUL characters are needed so that the string merging code in the linker will see separate strings for each command line option, not just one huge long option. The newline characters are not strictly necessary, but they improve the output from running "strings -a" on an executable containing the command line information.


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