USER_LABEL_PREFIX appear on internal assembler labels

Ian Lance Taylor
Wed Jan 15 01:01:00 GMT 2014

On Tue, Jan 14, 2014 at 12:35 PM, Benjamin Burtscher
<> wrote:
> I have a problem with internal assembler labels. We use #define USER_LABEL_PREFIX "_" in our i386 config to prefix global symbols.
> This is working, but the problem is that local internal assembler labels like ".L1" also get the prefix ("_.L1"), but not all of them. This produces unresolved symbols at the target.
> The -fleading-underscore switch produces the same problem.
> We can’t update to a newer version of GCC at the moment, because we use a third-party target platform.
> It would be great If you can tell me the interesting code lines where the problem could be so that I can fix it.
> I have attached 2 backtraces. In the first, the problem appears at a internal label. The second backtrace is the case where it works correctly with a global function.

You've got good backtraces.  You should look at each line in the
backtrace.  It ought to be fairly obvious what you need to change.  To
put it another way, if it's not obvious, you're going to have a lot of
trouble managing a private port of GCC.

> #0  assemble_name_raw (file=0x75182960 <msvcrt!_iob+96>, name=0x28f990 ".L19")
>     at ../../../../src/gcc-4.1.2/gcc/varasm.c:2034
> #1  0x0057148f in output_asm_label (x=<optimized out>) at ../../../../src/gcc-4.1.2/gcc/final.c:3184
> #2  0x00571d58 in output_asm_insn (operands=0x9395a0 <recog_data>,
>     template=0x8042e9 <eliminables.16431+9801> "%+j%C1  %l0") at ../../../../src/gcc-4.1.2/gcc/final.c:3092
> #3  output_asm_insn (template=0x8042e9 <eliminables.16431+9801> "%+j%C1 %l0", operands=0x9395a0 <recog_data>)
>     at ../../../../src/gcc-4.1.2/gcc/final.c:2958
> #4  0x005728c0 in final_scan_insn (insn=0x20e1850, file=0x75182960 <msvcrt!_iob+96>, optimize=0, nopeepholes=0,
>     seen=0x28fc0c) at ../../../../src/gcc-4.1.2/gcc/final.c:2499

For example, for this one you'll see that output_asm_label uses
ASM_GENERATE_INTERNAL_LABEL.  The definition of that is (probably) in
config/elfos.h.  Since ELF normally doesn't use a leading underscore,
there is no label prefix there.  Add a %U to that definition to get
the label prefix.


More information about the Gcc-help mailing list