Reputation: 6200
Is it possible to force gcc to store an array in a specific segment?
I want this
static const Host_Vtable_Entrty Host_vtable[]=
{
{"Window_create",(Function)Window_create}
,{"Window_cropEllipse",(Function)Window_cropEllipse}
,{"Window_cropRect",(Function)Window_cropRect}
,{"Window_cropRectRound",(Function)Window_cropRectRound}
,{"Window_destroy",(Function)Window_destroy}
,{"Window_filenameGet",(Function)Window_filenameGet}
,{"Window_filenameGet",(Function)Window_messageBox}
,{"Window_move",(Function)Window_move}
,{"Window_styleSet",(Function)Window_styleSet}
};
To be stored in a read-only place, but it is put in the data segment:
.data
.align 32
_ZL11Host_vtable:
.quad .LC0
.quad _Z13Window_createP6WindowP6ObjectPFyS2_PjyyEPFyS2_yPvE
.quad .LC1
.quad _Z18Window_cropEllipseP6Windowjdddd
.quad .LC2
.quad _Z15Window_cropRectP6Windowjdddd
.quad .LC3
.quad _Z20Window_cropRectRoundP6Windowjdddddd
.quad .LC4
.quad _Z14Window_destroyP6Window
.quad .LC5
.quad _Z18Window_filenameGetPcyPKcS1_j
.quad .LC5
.quad _Z17Window_messageBoxP6WindowPKcS2_j
.quad .LC6
.quad _Z11Window_moveP6Windowdddd
.quad .LC7
.quad _Z15Window_styleSetP6Windowjj
Do I need to write the assembly manually?
Upvotes: 0
Views: 665
Reputation: 409166
If you search the GCC documentation for GCC-specific extensions to the language, you will stumble upon a document describing variable attributes. Here you will find one attribute called segment
with examples on how to use it.
Upvotes: 1