This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: GDB multi-build failure in lm32-opc.c file


Dave Korn <dave.korn.cygwin@googlemail.com> a écrit?:

Pierre Muller wrote:

The easiest was finally to add an if (num_macros >= 1) before the memset call. When num_macros is zero, the call gets optimized out, and thus no warning is issued.

Does that still work at -O0?

You are right, this is not sure at all... But I tried it out, and got no error recompiling opcodes directory with make clean all CFLAGS="-g -O0"

It turned out to be necessary for 3 files.

  I had one more warning in  tic54x-dis.c file
about a call to sprintf with only two arguments.
Not sure the fix is the right one there...

           const char *code[] = { "eq", "lt", "gt", "neq" };
-          sprintf (operand[i], code[CC3 (opcode)]);
+          sprintf (operand[i], "%s", code[CC3 (opcode)]);
           info->fprintf_func (info->stream, "%s%s", comma, operand[i]);

Yeh, that looks good to me. The compiler's presumably worrying about some kind of potential for a format-string vulnerability. Although the strings pointed to by the code[] array are const, the pointers aren't, so effectively the strings could in theory be manipulated. Replacing the decl with "const char * const code[]" might fix it too, but who knows maybe some day somebody'll decide to generate the whole array algorithmically at runtime, so best to code defensively.

Could you check these in under the obvious rule?

I'd prefer to ask approval from a formal maintainer for anything much more complex than "pruntf"->"printf" sort of typo fixes if you don't mind. PING maintainers?

I was wondering if we should add some comment inside the source files themselves to explain why this condition was added... There might also be other solutions like adding some special gcc compile option to avoid that specific warning, but I have no clue of this can work... Especially as this warning seem to be placed directly into /usr/include/bits/string3.h.

  Would my GDB assignment be OK for a commit to opcodes?
This is really part of the code I need to compile GDB,
so it should be OK, no?
  Otherwise, can you submit it officially?

Thanks in advance,

Pierre Muller

GDB pascal language support maintainer.




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