bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error: can't resolve `.hcu.uncommon_code' {.hcu.uncommon_code sectio


From: Kristis Makris
Subject: Re: Error: can't resolve `.hcu.uncommon_code' {.hcu.uncommon_code section} - `.LFB17' {.text section}
Date: Mon, 23 Apr 2007 09:34:38 -0700

Hi Jim,

Thanks for the response. Indeed, there's no section change that would
position label LFE17 in the .text section, where main is.

On Sat, 2007-04-21 at 10:35 -0700, Jim Wilson wrote:
> It looks like you are trying to do some complicated (and probably
> fragile) section switching stuff in a C function using gcc extended
> asms, and that there is an unbalanced section switch somewhere.  Or
> maybe gcc optimization is breaking your code.

I wonder if this is a result of dead-code elimination by gcc, and if
there's a way to change this behavior. I've traced this down to the
following C code:

==============================================
hcu_wrapped_main_0_before:
/* more stuff */

if (var == 1)
{
hcu_save_frame_of_main_v1 ((void *) (&hcu_stack_local_main_var),
                           &hcu_stack_local_main_var.
                           hcu_stack_frame_fields, 2, 7);
return;
     hcu_wrapped_main_2_after:;
}
goto hcu_wrapped_main_0_before;

    __asm__ __volatile__ ("hcu_uncommon_section_"
                          "main_v1_hcu_wrapped_main_0_call_must_not"
                          ":\n\t");;
    __asm__ __volatile__ ("jmp 1f\n\t" ".text\n\t" "1:\n");;

==============================================

It seems that gcc does not even produce the inline assembly after the
last goto, perhaps because it is deemed that it's dead code. However, I
need this assembly produced to emit the section change to ".text". Is
there a way to tell gcc to NOT remove that inline assembly ? Is there
some attribute/keyword that describes this ? I haven't found one.

The only other alternative I see is to acquire the value of the
hcu_wrapped_main_0_before label using the && operator
(http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html) and write
something like:

 __asm__ __volatile__ ("jmp %0\n\t"
                       "hcu_uncommon_section_"
                          "main_v1_hcu_wrapped_main_0_call_must_not"
                          ":\n\t"
                        : /* no output */
                        : "g" (&&hcu_wrapped_main_0_before) );;
 __asm__ __volatile__ ("jmp 1f\n\t" ".text\n\t" "1:\n");;

It's not an ideal solution for two reasons. Labels as values are not ISO
C. And these assembly statements are produced using macros that could be
conditionally defined to something a lot more simpler (just a "}") when
cache locality is not an issue. I was hoping to keep those macros.

Thanks again,
Kristis





reply via email to

[Prev in Thread] Current Thread [Next in Thread]