removed double references and fixed float generation

This commit is contained in:
Julgodis 2021-03-30 01:29:50 +02:00
parent 815c1a2039
commit 88eb7be90c
3 changed files with 28 additions and 3 deletions

View File

@ -54,6 +54,9 @@ class ArbitraryData(Symbol):
exporter,
builder: AsyncBuilder,
c_export: bool = False):
if not c_export:
return
if self.is_static:
if not self.force_section and not self.require_forward_reference:
return
@ -64,7 +67,7 @@ class ArbitraryData(Symbol):
await self.export_extern(builder)
name = self.identifier.label
if not c_export and self.demangled_name:
if self.demangled_name:
name = self.demangled_name.to_str(specialize_templates=False,
without_template=False)

View File

@ -52,6 +52,15 @@ class CPPExporter:
await builder.write("")
break
for symbol in section.symbols:
if symbol.identifier.label == "__init_cpp_exceptions_reference":
continue
if symbol.identifier.label == "_ctors":
continue
await self.export_symbol_header(builder, symbol)
await symbol.export_declaration(self, builder)
await builder.write("")
async def export_section_dtors(self, builder: AsyncBuilder, section: Section):
await builder.write("#pragma section \".dtors$10\"")
for symbol in section.symbols:
@ -69,6 +78,15 @@ class CPPExporter:
await builder.write("")
break
for symbol in section.symbols:
if symbol.identifier.label == "__destroy_global_chain_reference":
continue
if symbol.identifier.label == "__fini_cpp_exceptions_reference":
continue
await self.export_symbol_header(builder, symbol)
await symbol.export_declaration(self, builder)
await builder.write("")
async def export_declarations(self,
builder: AsyncBuilder,
tu: TranslationUnit,

View File

@ -156,7 +156,9 @@ def value_initialized_symbol(section: Section,
# Metrowerks is very smart... if you initialize a float with 0.0f, the storage will be moved to the one of the .bss sections.
# Generated literals will always be (for floats and doubles) in the .sdata2 section. Thus, if we are a literal, we cannot
# use the value 0.0f.
if padding_values and len(values) > 0 and not (len(values) == 1 and values[0][0] == 0):
is_zero = (len(values) == 1 and values[0][0] == 0)
is_zero_and_no_padding = is_zero and len(padding_values) == 0
if len(values) > 0 and not is_zero_and_no_padding:
return [FloatingPoint.create_f32(identifier, symbol.addr, values, padding_values)]
if isinstance(symbol.access, DoubleLoadAccess):
@ -165,7 +167,9 @@ def value_initialized_symbol(section: Section,
padding_values = FloatingPoint.f64_from(padding_data)
# Same comments as for the float case.
if padding_values and len(values) > 0 and not (len(values) == 1 and values[0][0] == 0):
is_zero = (len(values) == 1 and values[0][0] == 0)
is_zero_and_no_padding = is_zero and len(padding_values) == 0
if len(values) > 0 and not is_zero_and_no_padding:
return [FloatingPoint.create_f64(identifier, symbol.addr, values, padding_values)]
if symbol.size == 4 and len(padding_data) % 4 == 0: