This is the mail archive of the gcc-bugs@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]

[Bug target/78838] New: msp430 option -mcode-region=either, -ffunction-sections, and interrupt function attributes cause incorrect section to be created


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78838

            Bug ID: 78838
           Summary: msp430 option -mcode-region=either,
                    -ffunction-sections, and interrupt function attributes
                    cause incorrect section to be created
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: awygle at gmail dot com
  Target Milestone: ---

On the msp430 target, when using -mcode-region with -ffunction-sections (as is
semi-suggested by the documentation), any functions which are marked with the
interrupt attribute and which also specify an interrupt number are placed into
an incorrect section ".either.lowtext", which is clearly nonsensical. An
example is below.

interrupt_bug.i:

# 1 "interrupt_bug.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "interrupt_bug.c"

__attribute__((interrupt(2))) void causes_error(void) {
}

void main() {

  while(1);
}

Compiling with -ffunction-sections:

% msp430-elf-gcc -msim -mlarge -mcode-region=either -ffunction-sections
-save-temps -c interrupt_bug.c -o interrupt_bug.o
% msp430-elf-gcc -msim -mlarge -mcode-region=either -ffunction-sections
-save-temps interrupt_bug.o -o interrupt_bug.elf
/home/awygle/toolchain/install/bin/../lib/gcc/msp430-elf/6.2.0/../../../../msp430-elf/bin/ld:
error: no section named .lower.lowtext or .upper.lowtext in linker script
% msp430-elf-objdump --syms interrupt_bug.o

interrupt_bug.o:     file format elf32-msp430

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 interrupt_bug.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .either.lowtext        00000000 .either.lowtext
00000000 l    d  __interrupt_vector_2   00000000 __interrupt_vector_2
00000000 l    d  .either.text.main      00000000 .either.text.main
00000000 l    d  .comment       00000000 .comment
00000000 l    d  .MSP430.attributes     00000000 .MSP430.attributes
00000000 g     F .either.lowtext        00000004 causes_error
00000000 g     F .either.text.main      00000004 main


Note that main() is in the section .either.text.main, while causes_error() is
in the section .either.lowtext.

Compiling without -ffunction-sections:

% msp430-elf-gcc -msim -mlarge -mcode-region=either -save-temps -c
interrupt_bug.c -o interrupt_bug.o
% msp430-elf-gcc -msim -mlarge -mcode-region=either -save-temps interrupt_bug.o
-o interrupt_bug.elf
% msp430-elf-objdump --syms interrupt_bug.o

interrupt_bug.o:     file format elf32-msp430

SYMBOL TABLE:
00000000 l    df *ABS*  00000000 interrupt_bug.c
00000000 l    d  .text  00000000 .text
00000000 l    d  .data  00000000 .data
00000000 l    d  .bss   00000000 .bss
00000000 l    d  .lowtext       00000000 .lowtext
00000000 l    d  __interrupt_vector_2   00000000 __interrupt_vector_2
00000000 l    d  .either.text   00000000 .either.text
00000000 l    d  .comment       00000000 .comment
00000000 l    d  .MSP430.attributes     00000000 .MSP430.attributes
00000000 g     F .lowtext       00000004 causes_error
00000000 g     F .either.text   00000004 main


Now causes_error() is in the .lowtext section, as expected.

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