Skip to content

Commit 19e7d05

Browse files
committed
fbc: compensate for section relocations in C backend change from gcc 7.x to 8.x
- C backend: switch to .text section after writing the exports to the C file in the explicit asm block. - gcc can move sections around with optimizations - there is a change between 7.x and 8.x that causes issue with where the directive section is located - in gcc 8.x the .drectve section can appear immediately after the first .text section and the .drectve section not properly closed.
1 parent dc85177 commit 19e7d05

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Version 1.07.3
33
[added]
44
- sf.net #898: fbc win gfxlib DirectX driver failed to initialize on 64-bit, due to incorrect construction of DIDATAFORMAT for keyboard device (macko17)
55

6+
[fixed]
7+
- C backend: switch to .text section after writing the exports to the C file in the explicit asm block. gcc can move sections around with optimizations and there is a change between 7.x and 8.x that causes issue with where the directive section is located
8+
9+
610
Version 1.07.2
711

812
[changed]

src/compiler/ir-hlc.bas

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,11 +1370,19 @@ private sub _emitEnd( )
13701370

13711371
sectionReturn( section )
13721372

1373+
'' even though we are putting this asm section at the end of the emitted C file
1374+
'' gcc might move it around when compiling the C lising and the ASM block ends up
1375+
'' (typically?) at the beginning of the C source. Appears to be a change in if
1376+
'' gcc locates this before or after the first '.text. directive when it writes out
1377+
'' the ASM listing from the C listing: somewhere between gcc 7.1 and gcc 7.4.
1378+
'' Explicity close the .drectve section by switching to .text section and presume
1379+
'' that it comensates for the gcc'a choice of section location.
13731380
'' DLL export table
13741381
if( env.clopt.export and (env.target.options and FB_TARGETOPT_EXPORT) ) then
13751382
symbForEachGlobal( FB_SYMBCLASS_PROC, @hMaybeEmitProcExport )
13761383
if( len( ctx.exports ) > 0 ) then
13771384
hWriteLine( !"\n__asm__( \n\t\".section .drectve\\n\"\n" + ctx.exports + ");", TRUE )
1385+
hWriteLine( "__asm__( "".text"" );" )
13781386
end if
13791387
ctx.exports = ""
13801388
end if

0 commit comments

Comments
 (0)