bebbo / binutils-gdb

Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
3 stars 3 forks source link

__chip has no effect #17

Closed githubaf closed 2 years ago

githubaf commented 2 years ago

It seems that the __chip keyword has no effect and is silently ignored.

#include <stdio.h>

__chip char ChipArray[]="I should be in Chip-Ram";
       char FastArray[]="I should be in Fast-Ram";

int main(void)
{
    printf("Chip is 0 ... 0x1fffff\n");
    printf("ChipArray     %08x <%s>\n",(unsigned int) ChipArray,ChipArray);
    printf("FastArray     %08x <%s>\n",(unsigned int) FastArray,FastArray);
    return 0;
}

compile with m68k-amigaos-gcc chip_fast.c -Wall --pedantic -noixemul -O2 -o chip_fast

When compiled with SAS/C it works correctly.

Btw: Did you remove SAS/C from your Compiler Explorer page?

bebbo commented 2 years ago

Btw: Did you remove SAS/C from your Compiler Explorer page?

switch to C - SAS/C does not support C++

githubaf commented 2 years ago

Btw: Did you remove SAS/C from your Compiler Explorer page?

switch to C - SAS/C does not support C++

Ah, I see.

bebbo commented 2 years ago

there's an underscore missing: .datachip should be .data_chip

githubaf commented 2 years ago

The old documentation http://cahirwpz.users.sourceforge.net/gcc-amigaos/chip.html#chip says

Note: For compatibility with other AmigaOS ‘C’ compilers, a preprocessor symbol ‘__chip’ is available, which expands to __attribute__((chip)) (see Keyword macros).

All the ‘chip’ attribute does is specifying that data should go to a section called ‘.datachip’. Therefore, the standard ‘GCC’ feature __attribute__((section(".datachip"))) can be used instead. 

There is no underscore?

bebbo commented 2 years ago

then it's a binutil issue

bebbo commented 2 years ago
#NO_APP
        .globl  _ChipArray
        .section .datachip
_ChipArray:

and

hunkdump test
reading test
hunk 000003f3,      HUNK_HEADER,          0
4 sections, 0 - 3 
sizes: 10252, 408, 140, 24(c)
...

note the (c) which indicates the chip attribute

githubaf commented 2 years ago

Yes, that issue is fixed. __chip works now. Thank you!