# define VARLOW __section(".discard.varlow." UNIQSEC) __VISIBLE __weak
// Designate a variable as visible and located in the f-segment.
# define VARFSEG __section(".discard.varfseg." UNIQSEC) __VISIBLE __weak
+// Verify a variable is only accessable via 32bit "init" functions
+# define VARVERIFY32INIT __section(".discard.varinit." UNIQSEC)
// Designate top-level assembler as 16bit only.
# define ASM16(code) __ASM(code)
// Designate top-level assembler as 32bit flat only.
# define VAR32SEG __section(".data32seg." UNIQSEC)
# define VARLOW __section(".discard.varlow." UNIQSEC) __VISIBLE __weak
# define VARFSEG __section(".discard.varfseg." UNIQSEC) __VISIBLE __weak
+# define VARVERIFY32INIT __section(".discard.varinit." UNIQSEC)
# define ASM16(code)
# define ASM32FLAT(code)
# define ASSERT16() __force_link_error__only_in_16bit()
# define VAR32SEG __section(".discard.var32seg." UNIQSEC)
# define VARLOW __section(".data.varlow." UNIQSEC) __VISIBLE __weak
# define VARFSEG __section(".data.varfseg." UNIQSEC) __VISIBLE
+# define VARVERIFY32INIT __section(".data.varinit." UNIQSEC)
# define ASM16(code)
# define ASM32FLAT(code) __ASM(code)
# define ASSERT16() __force_link_error__only_in_16bit()
# Detection of init code
######################################################################
-def markRuntime(section, sections):
+def markRuntime(section, sections, chain=[]):
if (section is None or not section.keep or section.category is not None
or '.init.' in section.name or section.fileid != '32flat'):
return
+ if '.data.varinit.' in section.name:
+ print "ERROR: %s is VARVERIFY32INIT but used from %s" % (
+ section.name, chain)
+ sys.exit(1)
section.category = '32flat'
# Recursively mark all sections this section points to
for reloc in section.relocs:
- markRuntime(reloc.symbol.section, sections)
+ markRuntime(reloc.symbol.section, sections, chain + [section.name])
-def findInit(sections):
+def findInit(sections, genreloc):
# Recursively find and mark all "runtime" sections.
for section in sections:
if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name
for section in sections:
if section.category is not None:
continue
- if section.fileid == '32flat':
+ if section.fileid == '32flat' and genreloc:
section.category = '32init'
else:
section.category = section.fileid
# Separate 32bit flat into runtime and init parts
genreloc = '_reloc_abs_start' in info32flat[1]
- if genreloc:
- findInit(sections)
- else:
- for section in sections:
- section.category = section.fileid
+ findInit(sections, genreloc)
# Note "low memory" and "fseg memory" parts
for section in getSectionsPrefix(sections, '.data.varlow.'):