Skip to content

Commit 11b2961

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 ee2df00 commit 11b2961

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Version 1.08.0
119119
- gcc backend: inline asm for float to integer calculations was generating bad code with gcc optimizations due to x87 stack clobbered but not reported to gcc
120120
- gcc backend: fix GOSUB causing crash/exception on win64 - setjmp/longjmp failed on mingw-w64 64-bit and needed to be passed 2 parameters instead of 1
121121
- fix __FB_EVAL__() incorrectly reading past the end of the expression, and report errors in expressions
122+
- 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
122123

123124

124125
Version 1.07.0

src/compiler/ir-hlc.bas

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

13721372
sectionReturn( section )
13731373

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

0 commit comments

Comments
 (0)