3232* DATA DECLARATIONS
3333*/
3434typedef enum {
35+ K_PSUEDO_FOREIGN_LD_SCRIPT_SYMBOL = -4 ,
3536 K_PSUEDO_FOREIGN_LD_SCRIPT_SECTION = -3 ,
3637 K_PSUEDO_MACRO_END = -2 ,
3738 K_NONE = -1 , K_DEFINE , K_LABEL , K_MACRO , K_TYPE ,
@@ -49,6 +50,7 @@ typedef enum {
4950 OP_ENDS ,
5051 OP_EQU ,
5152 OP_EQUAL ,
53+ OP_GLOBAL ,
5254 OP_LABEL ,
5355 OP_MACRO ,
5456 OP_PROC ,
@@ -96,6 +98,8 @@ static const keywordTable AsmKeywords [] = {
9698 { "endp" , OP_ENDP },
9799 { "ends" , OP_ENDS },
98100 { "equ" , OP_EQU },
101+ { "global" , OP_GLOBAL },
102+ { "globl" , OP_GLOBAL },
99103 { "label" , OP_LABEL },
100104 { "macro" , OP_MACRO },
101105 { ":=" , OP_COLON_EQUAL },
@@ -124,6 +128,7 @@ static const opKind OpKinds [] = {
124128 { OP_ENDS , K_NONE },
125129 { OP_EQU , K_DEFINE },
126130 { OP_EQUAL , K_DEFINE },
131+ { OP_GLOBAL , K_PSUEDO_FOREIGN_LD_SCRIPT_SYMBOL },
127132 { OP_LABEL , K_LABEL },
128133 { OP_MACRO , K_MACRO },
129134 { OP_PROC , K_LABEL },
@@ -203,7 +208,7 @@ static bool isDefineOperator (const vString *const operator)
203208 return result ;
204209}
205210
206- static int makeTagForLdScriptSection (const char * section )
211+ static int makeTagForLdScript (const char * name , int kind , int * scope )
207212{
208213 tagEntryInfo e ;
209214 static langType lang = LANG_AUTO ;
@@ -213,20 +218,36 @@ static int makeTagForLdScriptSection (const char * section)
213218 if (lang == LANG_IGNORE )
214219 return CORK_NIL ;
215220
216- static kindDefinition * kdef = NULL ;
217- if (kdef == NULL )
218- kdef = getLanguageKindForName (lang , "inputSection" );
219- if (kdef == NULL )
220- return CORK_NIL ;
221-
222- static roleDefinition * rdef = NULL ;
223- if (rdef == NULL )
224- rdef = getLanguageRoleForName (lang , kdef -> id , "destination" );
225- if (rdef == NULL )
226- return CORK_NIL ;
227-
228- initForeignRefTagEntry (& e , section , lang , kdef -> id , rdef -> id );
229- return makeTagEntry (& e );
221+ if (kind == K_PSUEDO_FOREIGN_LD_SCRIPT_SYMBOL )
222+ {
223+ static kindDefinition * kdef = NULL ;
224+ if (kdef == NULL )
225+ kdef = getLanguageKindForName (lang , "symbol" );
226+ if (kdef == NULL )
227+ return CORK_NIL ;
228+
229+ initForeignTagEntry (& e , name , lang , kdef -> id );
230+ e .extensionFields .scopeIndex = * scope ;
231+ return makeTagEntry (& e );
232+ }
233+ else
234+ {
235+ static kindDefinition * kdef = NULL ;
236+ if (kdef == NULL )
237+ kdef = getLanguageKindForName (lang , "inputSection" );
238+ if (kdef == NULL )
239+ return CORK_NIL ;
240+
241+ static roleDefinition * rdef = NULL ;
242+ if (rdef == NULL )
243+ rdef = getLanguageRoleForName (lang , kdef -> id , "destination" );
244+ if (rdef == NULL )
245+ return CORK_NIL ;
246+
247+ initForeignRefTagEntry (& e , name , lang , kdef -> id , rdef -> id );
248+ * scope = makeTagEntry (& e );
249+ return * scope ;
250+ }
230251}
231252
232253static int makeAsmTag (
@@ -235,6 +256,7 @@ static int makeAsmTag (
235256 const bool labelCandidate ,
236257 const bool nameFollows ,
237258 const bool directive ,
259+ int * sectionScope ,
238260 int * macroScope )
239261{
240262 int r = CORK_NIL ;
@@ -258,7 +280,9 @@ static int makeAsmTag (
258280 {
259281 operatorKind (name , & found );
260282 if (! found )
283+ {
261284 r = makeSimpleTag (name , K_LABEL );
285+ }
262286 }
263287 else if (directive )
264288 {
@@ -288,8 +312,10 @@ static int makeAsmTag (
288312 * macroScope = macro_tag -> extensionFields .scopeIndex ;
289313 }
290314 break ;
315+ case K_PSUEDO_FOREIGN_LD_SCRIPT_SYMBOL :
291316 case K_PSUEDO_FOREIGN_LD_SCRIPT_SECTION :
292- r = makeTagForLdScriptSection (vStringValue (operator ));
317+ r = makeTagForLdScript (vStringValue (operator ),
318+ kind_for_directive , sectionScope );
293319 break ;
294320 default :
295321 r = makeSimpleTag (operator , kind_for_directive );
@@ -718,6 +744,7 @@ static void findAsmTagsCommon (bool useCpp)
718744 KIND_GHOST_INDEX , 0 , 0 , KIND_GHOST_INDEX , KIND_GHOST_INDEX , 0 , 0 ,
719745 FIELD_UNKNOWN );
720746
747+ int sectionScope = CORK_NIL ;
721748 int macroScope = CORK_NIL ;
722749
723750 while ((line = asmReadLineFromInputFile (commentCharsInMOL , useCpp )) != NULL )
@@ -782,7 +809,8 @@ static void findAsmTagsCommon (bool useCpp)
782809 cp = readSymbol (cp , name );
783810 nameFollows = true;
784811 }
785- int r = makeAsmTag (name , operator , labelCandidate , nameFollows , directive , & macroScope );
812+ int r = makeAsmTag (name , operator , labelCandidate , nameFollows , directive ,
813+ & sectionScope , & macroScope );
786814 tagEntryInfo * e = getEntryInCorkQueue (r );
787815 if (e && e -> langType == Lang_asm
788816 && e -> kindIndex == K_MACRO && isRoleAssigned (e , ROLE_DEFINITION_INDEX ))
0 commit comments