Xref: news2.mv.net comp.os.msdos.djgpp:6545 Newsgroups: comp.os.msdos.djgpp From: hk AT bercos DOT de (Helge Kruse) Subject: Re: __attribute__((section)) Reply-To: hk AT bercos DOT de Organization: BERCOS GmbH Berlin, Germany Message-ID: References: Date: Mon, 29 Jul 1996 19:34:04 GMT Lines: 78 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Mark Habersack (grendel AT ananke DOT amu DOT edu DOT pl) wrote: : For one moment I suspected that I cannot use __attribute__(section) because : djgpp doesn't know how to switch data segments, which would be necessary to : acces the data in other sections which are not in the same address : space as BSS & DATA (but then it is only a matter of an entry in djgpp.ld, : isn't it? Of course, it is not possible to specify any section by default in : that script, but that should not impose any restrictions on the compiler : itself) - is that the reason? If you like to look at a quick and dirty hack, here it is: ----- makefile ----- CC=gcc DJGPP=c:/djgpp sample: sample.o specdat.o ld -Tdjgpp.lnk -o $@ $(DJGPP)/lib/crt0.o -L$(DJGPP)/lib $^ -lgcc -lc -lgcc sample.o: sample.c specdat.o: specdat.c $(CC) -S $< -o $*.sx sed "s/\.data/.section MYDATA/" <$*.sx >$*.s $(CC) -c $*.s -o $@ show: sample objdump -h $< clean: rm -f sample *.o *.s* *.bak ----- sample.c ----- #include "specdat.h" int maindata; void main(void) { maindata=specdata; } ----- specdat.h ----- extern int specdata; ----- specdat.c ----- #include "specdat.h" /* ONLY use initialized data! */ /* uninitialized data goes to .bss and cannot be moved */ int specdata=0; /* section attributes are not supported for this target int me __attribute ((section("MYDATA"))); */ ----- djgpp.lnk ----- OUTPUT_FORMAT("coff-go32") ENTRY(start) SECTIONS { .text : { *(.text) etext = . ; _etext = .; . = ALIGN(0x200); } .data ALIGN(0x200) : { *(.data) *(.bss) edata = . ; _edata = .; . = ALIGN(0x200); } MYDATA 0x1234 : { _mydata = . ; *(MYDATA) _emydata = . ; } } ----- end ----- The djgpp.lnk is written from mind, so check it against the system file. Regards, Helge