gcc should never inline functions which have a 'section' attribute set
on them.

If the section is placed at a specific location in memory via a linker
script, then the function will not be placed into its correct address,
and the resultant executable is incorrect.

gcc 4.1.1 will inline static function at -O1 and -O2, but not -O0 and
-O3; this can be seen by compiling the attached test program at
various optimization levels.

    static int __attribute__((section(".special_section"))) 
    special_function_0(void)
    {
       return 0;
    }

    int __attribute__((section(".special_section"))) 
    special_function_1(void)
    {
       return 0;
    }

    int main(void)
    {
       special_function_0();
       special_function_1();
       return 0;
    }


-- 
           Summary: gcc should not inline functions with 'section' attribute
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: thutt at vmware dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31362

Reply via email to