Explorar o código

Rebase to revision 18000

git-svn-id: branches/svenbarth/generics@18005 -
svenbarth %!s(int64=14) %!d(string=hai) anos
pai
achega
a862cd702d
Modificáronse 100 ficheiros con 3524 adicións e 2044 borrados
  1. 195 17
      .gitattributes
  2. 20 22
      Makefile
  3. 82 35
      compiler/Makefile
  4. 53 6
      compiler/Makefile.fpc
  5. 5 3
      compiler/aasmdata.pas
  6. 73 86
      compiler/aggas.pas
  7. 2 1
      compiler/arm/cgcpu.pas
  8. 1 1
      compiler/arm/narmcnv.pas
  9. 77 2
      compiler/assemble.pas
  10. 21 11
      compiler/avr/cgcpu.pas
  11. 5 2
      compiler/avr/cpubase.pas
  12. 6 16
      compiler/cclasses.pas
  13. 4 4
      compiler/cfileutl.pas
  14. 60 8
      compiler/cmsgs.pas
  15. 2 2
      compiler/compinnr.inc
  16. 4 0
      compiler/constexp.pas
  17. 41 4
      compiler/dbgdwarf.pas
  18. 8 2
      compiler/dbgstabs.pas
  19. 16 6
      compiler/defcmp.pas
  20. 11 3
      compiler/defutil.pas
  21. 25 6
      compiler/fmodule.pas
  22. 17 0
      compiler/fpcdefs.inc
  23. 5 1
      compiler/fppu.pas
  24. 51 0
      compiler/generic/cpuinfo.pas
  25. 36 21
      compiler/globals.pas
  26. 25 3
      compiler/globtype.pas
  27. 19 2
      compiler/htypechk.pas
  28. 30 1
      compiler/i386/cgcpu.pas
  29. 1 1
      compiler/i386/cputarg.pas
  30. 1 1
      compiler/i386/i386nop.inc
  31. 23 16
      compiler/i386/i386tab.inc
  32. 6 4
      compiler/i386/popt386.pas
  33. 183 18
      compiler/link.pas
  34. 4 4
      compiler/m68k/n68kadd.pas
  35. 2 2
      compiler/mips/aasmcpu.pas
  36. 1 1
      compiler/mips/cgcpu.pas
  37. 2 2
      compiler/mips/cpuinfo.pas
  38. 1 1
      compiler/mips/ncpucnv.pas
  39. 41 14
      compiler/msg/errore.msg
  40. 5 3
      compiler/msgidx.inc
  41. 393 388
      compiler/msgtxt.inc
  42. 70 61
      compiler/nadd.pas
  43. 2 2
      compiler/nbas.pas
  44. 23 4
      compiler/ncal.pas
  45. 23 8
      compiler/ncgadd.pas
  46. 35 91
      compiler/ncgcon.pas
  47. 4 4
      compiler/ncginl.pas
  48. 8 7
      compiler/ncgrtti.pas
  49. 1 33
      compiler/ncgutil.pas
  50. 8 8
      compiler/ncnv.pas
  51. 17 12
      compiler/nflw.pas
  52. 101 11
      compiler/ninl.pas
  53. 18 15
      compiler/nmat.pas
  54. 3 4
      compiler/nobj.pas
  55. 6 6
      compiler/nset.pas
  56. 134 10
      compiler/ogbase.pas
  57. 119 14
      compiler/ogcoff.pas
  58. 30 5
      compiler/ogelf.pas
  59. 7 2
      compiler/ognlm.pas
  60. 1 1
      compiler/optcse.pas
  61. 101 42
      compiler/options.pas
  62. 5 0
      compiler/parser.pas
  63. 15 51
      compiler/pdecsub.pas
  64. 35 10
      compiler/pdecvar.pas
  65. 2 2
      compiler/pexpr.pas
  66. 3 7
      compiler/pmodules.pas
  67. 7 68
      compiler/powerpc/agppcmpw.pas
  68. 1 1
      compiler/powerpc/cgcpu.pas
  69. 1 1
      compiler/powerpc64/rappcgas.pas
  70. 3 2
      compiler/ppcgen/cgppc.pas
  71. 4 4
      compiler/ppcgen/ngppcadd.pas
  72. 179 35
      compiler/ppu.pas
  73. 45 0
      compiler/pstatmnt.pas
  74. 20 2
      compiler/psub.pas
  75. 24 12
      compiler/psystem.pas
  76. 26 2
      compiler/ptconst.pas
  77. 4 3
      compiler/ptype.pas
  78. 14 2
      compiler/scandir.pas
  79. 3 2
      compiler/sparc/cgcpu.pas
  80. 1 1
      compiler/sparc/ncpucnv.pas
  81. 2 2
      compiler/sparc/racpugas.pas
  82. 24 1
      compiler/switches.pas
  83. 2 1
      compiler/symconst.pas
  84. 87 9
      compiler/symdef.pas
  85. 3 4
      compiler/symtable.pas
  86. 216 0
      compiler/systems.inc
  87. 51 212
      compiler/systems.pas
  88. 1 1
      compiler/systems/i_linux.pas
  89. 4 3
      compiler/systems/t_emx.pas
  90. 5 14
      compiler/systems/t_linux.pas
  91. 4 14
      compiler/systems/t_nds.pas
  92. 2 1
      compiler/systems/t_nwm.pas
  93. 9 7
      compiler/systems/t_os2.pas
  94. 64 4
      compiler/systems/t_win.pas
  95. 74 4
      compiler/utils/Makefile
  96. 20 2
      compiler/utils/Makefile.fpc
  97. 18 0
      compiler/utils/gppc386.pp
  98. 31 35
      compiler/utils/mkx86reg.pp
  99. 206 463
      compiler/utils/ppudump.pp
  100. 41 2
      compiler/verbose.pas

+ 195 - 17
.gitattributes

@@ -146,12 +146,12 @@ compiler/fpccrc.pas svneol=native#text/plain
 compiler/fpcdefs.inc svneol=native#text/plain
 compiler/fppu.pas svneol=native#text/plain
 compiler/gendef.pas svneol=native#text/plain
+compiler/generic/cpuinfo.pas svneol=native#text/plain
 compiler/globals.pas svneol=native#text/plain
 compiler/globtype.pas svneol=native#text/plain
 compiler/html/i386/readme.txt svneol=native#text/plain
 compiler/html/powerpc/readme.txt svneol=native#text/plain
 compiler/htypechk.pas svneol=native#text/plain
-compiler/i386/ag386nsm.pas svneol=native#text/plain
 compiler/i386/aopt386.pas svneol=native#text/plain
 compiler/i386/cgcpu.pas svneol=native#text/plain
 compiler/i386/cpubase.inc svneol=native#text/plain
@@ -517,6 +517,7 @@ compiler/symsym.pas svneol=native#text/plain
 compiler/symtable.pas svneol=native#text/plain
 compiler/symtype.pas svneol=native#text/plain
 compiler/symutil.pas svneol=native#text/plain
+compiler/systems.inc svneol=native#text/plain
 compiler/systems.pas svneol=native#text/plain
 compiler/systems/i_amiga.pas svneol=native#text/plain
 compiler/systems/i_atari.pas svneol=native#text/plain
@@ -614,6 +615,7 @@ compiler/wpoinfo.pas svneol=native#text/plain
 compiler/x86/aasmcpu.pas svneol=native#text/plain
 compiler/x86/agx86att.pas svneol=native#text/plain
 compiler/x86/agx86int.pas svneol=native#text/plain
+compiler/x86/agx86nsm.pas svneol=native#text/plain
 compiler/x86/cga.pas svneol=native#text/plain
 compiler/x86/cgx86.pas svneol=native#text/plain
 compiler/x86/cpubase.pas svneol=native#text/plain
@@ -1629,6 +1631,7 @@ packages/dts/fpmake.pp svneol=native#text/plain
 packages/dts/src/dts.pas svneol=native#text/plain
 packages/fastcgi/Makefile svneol=native#text/plain
 packages/fastcgi/Makefile.fpc svneol=native#text/plain
+packages/fastcgi/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/fastcgi/fpmake.pp svneol=native#text/plain
 packages/fastcgi/src/fastcgi.pp svneol=native#text/plain
 packages/fcl-async/Makefile svneol=native#text/plain
@@ -1654,7 +1657,6 @@ packages/fcl-base/examples/base64decodingtestcase.pas svneol=native#text/plain
 packages/fcl-base/examples/cachetest.pp svneol=native#text/plain
 packages/fcl-base/examples/cfgtest.pp svneol=native#text/plain
 packages/fcl-base/examples/crittest.pp svneol=native#text/plain
-packages/fcl-base/examples/daemon.txt svneol=native#text/plain
 packages/fcl-base/examples/dbugsrv.pp svneol=native#text/plain
 packages/fcl-base/examples/debugtest.pp svneol=native#text/plain
 packages/fcl-base/examples/decodeascii85.pp svneol=native#text/plain
@@ -1996,6 +1998,7 @@ packages/fcl-extra/Makefile.fpc svneol=native#text/plain
 packages/fcl-extra/examples/Makefile svneol=native#text/plain
 packages/fcl-extra/examples/Makefile.fpc svneol=native#text/plain
 packages/fcl-extra/examples/daemon.pp svneol=native#text/plain
+packages/fcl-extra/examples/daemon.txt svneol=native#text/plain
 packages/fcl-extra/fpmake.pp svneol=native#text/pascal
 packages/fcl-extra/src/daemonapp.pp svneol=native#text/plain
 packages/fcl-extra/src/unix/daemonapp.inc svneol=native#text/plain
@@ -2110,7 +2113,7 @@ packages/fcl-image/src/xwdfile.pp svneol=native#text/plain
 packages/fcl-js/Makefile svneol=native#text/plain
 packages/fcl-js/Makefile.fpc svneol=native#text/plain
 packages/fcl-js/README.TXT svneol=native#text/plain
-packages/fcl-js/fpmake_disabled.pp svneol=native#text/plain
+packages/fcl-js/fpmake.pp svneol=native#text/plain
 packages/fcl-js/src/jsbase.pp svneol=native#text/plain
 packages/fcl-js/src/jsparser.pp svneol=native#text/plain
 packages/fcl-js/src/jsscanner.pp svneol=native#text/plain
@@ -2199,6 +2202,7 @@ packages/fcl-process/src/dummy/simpleipc.inc svneol=native#text/plain
 packages/fcl-process/src/os2/pipes.inc svneol=native#text/plain
 packages/fcl-process/src/os2/simpleipc.inc svneol=native#text/plain
 packages/fcl-process/src/pipes.pp svneol=native#text/plain
+packages/fcl-process/src/pipesipc.pp svneol=native#text/plain
 packages/fcl-process/src/process.pp svneol=native#text/plain
 packages/fcl-process/src/process.txt svneol=native#text/plain
 packages/fcl-process/src/simpleipc.pp svneol=native#text/plain
@@ -2352,8 +2356,7 @@ packages/fcl-stl/tests/suiteconfig.pp svneol=native#text/plain
 packages/fcl-stl/tests/testrunner.pp svneol=native#text/plain
 packages/fcl-web/Makefile svneol=native#text/plain
 packages/fcl-web/Makefile.fpc svneol=native#text/plain
-packages/fcl-web/Makefile.fpm svneol=native#text/plain
-packages/fcl-web/Makefile_fpmake.fpc svneol=native#text/plain
+packages/fcl-web/Makefile.fpc.fpcmake svneol=native#text/plain
 packages/fcl-web/examples/combined/combined.html svneol=native#text/plain
 packages/fcl-web/examples/combined/combined.ico -text
 packages/fcl-web/examples/combined/combined.ini svneol=native#text/plain
@@ -2369,8 +2372,151 @@ packages/fcl-web/examples/combined/users.sql svneol=native#text/plain
 packages/fcl-web/examples/combined/wmlogin.lfm svneol=native#text/plain
 packages/fcl-web/examples/combined/wmlogin.pp svneol=native#text/plain
 packages/fcl-web/examples/combined/wmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/combined/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/combined/wmusers.pp svneol=native#text/plain
+packages/fcl-web/examples/echo/README.txt svneol=native#text/plain
+packages/fcl-web/examples/echo/apache/echo.lpi svneol=native#text/plain
+packages/fcl-web/examples/echo/apache/echo.lpr svneol=native#text/plain
+packages/fcl-web/examples/echo/apache/echo.res -text
+packages/fcl-web/examples/echo/cgi/echo.lpi svneol=native#text/plain
+packages/fcl-web/examples/echo/cgi/echo.lpr svneol=native#text/plain
+packages/fcl-web/examples/echo/cgi/echo.res -text
+packages/fcl-web/examples/echo/fcgi/echo.lpi svneol=native#text/plain
+packages/fcl-web/examples/echo/fcgi/echo.lpr svneol=native#text/plain
+packages/fcl-web/examples/echo/fcgi/echo.res -text
+packages/fcl-web/examples/echo/webmodule/wmecho.lfm svneol=native#text/plain
+packages/fcl-web/examples/echo/webmodule/wmecho.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/apache/embedtemplates.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/apache/embedtemplates.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/apache/embedtemplates.res -text
+packages/fcl-web/examples/fptemplate/embedtemplates/cgi/embedtemplates.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/cgi/embedtemplates.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/cgi/embedtemplates.res -text
+packages/fcl-web/examples/fptemplate/embedtemplates/fcgi/embedtemplates.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/fcgi/embedtemplates.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/fcgi/embedtemplates.res -text
+packages/fcl-web/examples/fptemplate/embedtemplates/templates/body.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/templates/body_left.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/templates/body_right.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/templates/bottom.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/templates/maintemplate.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/templates/top.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/embedtemplates/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/apache/fileupload.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/apache/fileupload.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/apache/fileupload.res -text
+packages/fcl-web/examples/fptemplate/fileupload/cgi/fileupload.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/cgi/fileupload.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/cgi/fileupload.res -text
+packages/fcl-web/examples/fptemplate/fileupload/fcgi/fileupload.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/fcgi/fileupload.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/fcgi/fileupload.res -text
+packages/fcl-web/examples/fptemplate/fileupload/templates/uploadform.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/fileupload/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/apache/listrecords.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/apache/listrecords.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/apache/listrecords.res -text
+packages/fcl-web/examples/fptemplate/listrecords/cgi/listrecords.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/cgi/listrecords.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/cgi/listrecords.res -text
+packages/fcl-web/examples/fptemplate/listrecords/fcgi/listrecords.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/fcgi/listrecords.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/fcgi/listrecords.res -text
+packages/fcl-web/examples/fptemplate/listrecords/templates/mytemplate3.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/listrecords/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/apache/autosession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/apache/autosession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/apache/autosession.res -text
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/cgi/autosession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/cgi/autosession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/cgi/autosession.res -text
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/fcgi/autosession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/fcgi/autosession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/fcgi/autosession.res -text
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/templates/autosession-template.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-auto/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/apache/cookiesession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/apache/cookiesession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/apache/cookiesession.res -text
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/cgi/cookiesession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/cgi/cookiesession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/cgi/cookiesession.res -text
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/fcgi/cookiesession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/fcgi/cookiesession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/fcgi/cookiesession.res -text
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/templates/testlogin.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/templates/testlogout.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/templates/testsomepage.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/templates/testwelcome.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/templates/userdb.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/cookiesessions-login/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/apache/urlsession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/apache/urlsession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/apache/urlsession.res -text
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/cgi/urlsession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/cgi/urlsession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/cgi/urlsession.res -text
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/fcgi/urlsession.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/fcgi/urlsession.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/fcgi/urlsession.res -text
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/templates/testurllogin.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/templates/testurllogout.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/templates/testurlsomepage.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/templates/testurlwelcome.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/templates/userdb.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/sessions/urlsessions-login/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/apache/simpletemplate.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/apache/simpletemplate.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/apache/simpletemplate.res -text
+packages/fcl-web/examples/fptemplate/simpletemplate/cgi/simpletemplate.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/cgi/simpletemplate.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/cgi/simpletemplate.res -text
+packages/fcl-web/examples/fptemplate/simpletemplate/fcgi/simpletemplate.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/fcgi/simpletemplate.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/fcgi/simpletemplate.res -text
+packages/fcl-web/examples/fptemplate/simpletemplate/templates/mytemplate1.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/simpletemplate/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/README.txt svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/apache/tagparam.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/apache/tagparam.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/apache/tagparam.res -text
+packages/fcl-web/examples/fptemplate/tagparam/cgi/tagparam.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/cgi/tagparam.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/cgi/tagparam.res -text
+packages/fcl-web/examples/fptemplate/tagparam/fcgi/tagparam.lpi svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/fcgi/tagparam.lpr svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/fcgi/tagparam.res -text
+packages/fcl-web/examples/fptemplate/tagparam/templates/mytemplate2.html svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/fptemplate/tagparam/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/helloworld/README.txt svneol=native#text/plain
+packages/fcl-web/examples/helloworld/apache/helloworld.lpi svneol=native#text/plain
+packages/fcl-web/examples/helloworld/apache/helloworld.lpr svneol=native#text/plain
+packages/fcl-web/examples/helloworld/apache/helloworld.res -text
+packages/fcl-web/examples/helloworld/cgi/helloworld.lpi svneol=native#text/plain
+packages/fcl-web/examples/helloworld/cgi/helloworld.lpr svneol=native#text/plain
+packages/fcl-web/examples/helloworld/cgi/helloworld.res -text
+packages/fcl-web/examples/helloworld/fcgi/helloworld.lpi svneol=native#text/plain
+packages/fcl-web/examples/helloworld/fcgi/helloworld.lpr svneol=native#text/plain
+packages/fcl-web/examples/helloworld/fcgi/helloworld.res -text
+packages/fcl-web/examples/helloworld/webmodule/webmodule.lfm svneol=native#text/plain
+packages/fcl-web/examples/helloworld/webmodule/webmodule.pas svneol=native#text/plain
+packages/fcl-web/examples/httpapp/testhttp.lpi svneol=native#text/plain
+packages/fcl-web/examples/httpapp/testhttp.pp svneol=native#text/plain
 packages/fcl-web/examples/httpclient/httpget.lpi svneol=native#text/plain
 packages/fcl-web/examples/httpclient/httpget.pas svneol=native#text/plain
 packages/fcl-web/examples/httpclient/httppost.lpi svneol=native#text/plain
@@ -2387,7 +2533,6 @@ packages/fcl-web/examples/jsonrpc/demo1/echobatch.in svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/extdirect.in svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/notification.in svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/wmdemo.lfm svneol=native#text/plain
-packages/fcl-web/examples/jsonrpc/demo1/wmdemo.lrs svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/demo1/wmdemo.pp svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/extdirect/extdemo.html svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/extdirect/extdemo.js svneol=native#text/plain
@@ -2395,8 +2540,11 @@ packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpi svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/extdirect/extdemo.lpr svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/extdirect/extdirect.in svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/extdirect/wmext.lfm svneol=native#text/plain
-packages/fcl-web/examples/jsonrpc/extdirect/wmext.lrs svneol=native#text/plain
 packages/fcl-web/examples/jsonrpc/extdirect/wmext.pp svneol=native#text/plain
+packages/fcl-web/examples/session/sessiondemo.lpi svneol=native#text/plain
+packages/fcl-web/examples/session/sessiondemo.lpr svneol=native#text/plain
+packages/fcl-web/examples/session/wmsession.lfm svneol=native#text/plain
+packages/fcl-web/examples/session/wmsession.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/createusers.lpi svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/createusers.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/extgrid-json.html svneol=native#text/plain
@@ -2408,7 +2556,6 @@ packages/fcl-web/examples/webdata/demo/extgrid.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/lazwebdata.pas svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/reglazwebdata.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/wmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo/wmusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo2/extgrid-json.html svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo2/extgrid-json.js svneol=native#text/plain
@@ -2417,7 +2564,6 @@ packages/fcl-web/examples/webdata/demo2/extgrid-xml.js svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo2/extgrid.lpi svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo2/extgrid.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo2/wmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo2/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo2/wmusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/extgrid-json.html svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/extgrid-json.js svneol=native#text/plain
@@ -2426,13 +2572,10 @@ packages/fcl-web/examples/webdata/demo3/extgrid-xml.js svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/extgrid.lpi svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/extgrid.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/tralala.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo3/tralala.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/tralala.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/wmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo3/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo3/wmusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/dmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo4/dmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/dmusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/extgrid-json.html svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/extgrid-json.js svneol=native#text/plain
@@ -2441,10 +2584,8 @@ packages/fcl-web/examples/webdata/demo4/extgrid-xml.js svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/extgrid.lpi svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/extgrid.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/wmjsonusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo4/wmjsonusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/wmjsonusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/wmxmlusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo4/wmxmlusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo4/wmxmlusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo5/extgrid-json.html svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo5/extgrid-json.js svneol=native#text/plain
@@ -2453,7 +2594,6 @@ packages/fcl-web/examples/webdata/demo5/extgrid-xml.js svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo5/extgrid.lpi svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo5/extgrid.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo5/wmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo5/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo5/wmusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo6/extgrid-json.html svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo6/extgrid-json.js svneol=native#text/plain
@@ -2463,17 +2603,18 @@ packages/fcl-web/examples/webdata/demo6/extgrid.ini svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo6/extgrid.lpi svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo6/extgrid.lpr svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo6/wmusers.lfm svneol=native#text/plain
-packages/fcl-web/examples/webdata/demo6/wmusers.lrs svneol=native#text/plain
 packages/fcl-web/examples/webdata/demo6/wmusers.pp svneol=native#text/plain
 packages/fcl-web/examples/webdata/demos.txt svneol=native#text/plain
 packages/fcl-web/examples/webdata/users.dbf -text
 packages/fcl-web/fpmake.pp svneol=native#text/plain
+packages/fcl-web/src/base/FCGI-README.txt svneol=native#text/plain
 packages/fcl-web/src/base/Makefile svneol=native#text/plain
 packages/fcl-web/src/base/Makefile.fpc svneol=native#text/plain
 packages/fcl-web/src/base/README.txt svneol=native#text/plain
 packages/fcl-web/src/base/cgiapp.pp svneol=native#text/plain
 packages/fcl-web/src/base/custcgi.pp svneol=native#text/plain
 packages/fcl-web/src/base/custfcgi.pp svneol=native#text/plain
+packages/fcl-web/src/base/custhttpapp.pp svneol=native#text/plain
 packages/fcl-web/src/base/custweb.pp svneol=native#text/plain
 packages/fcl-web/src/base/ezcgi.pp svneol=native#text/plain
 packages/fcl-web/src/base/fcgigate.pp svneol=native#text/plain
@@ -2483,9 +2624,11 @@ packages/fcl-web/src/base/fpdatasetform.pp svneol=native#text/plain
 packages/fcl-web/src/base/fpfcgi.pp svneol=native#text/plain
 packages/fcl-web/src/base/fphtml.pp svneol=native#text/plain
 packages/fcl-web/src/base/fphttp.pp svneol=native#text/plain
+packages/fcl-web/src/base/fphttpapp.pp svneol=native#text/plain
 packages/fcl-web/src/base/fphttpclient.pp svneol=native#text/plain
 packages/fcl-web/src/base/fphttpserver.pp svneol=native#text/plain
 packages/fcl-web/src/base/fpweb.pp svneol=native#text/plain
+packages/fcl-web/src/base/fpwebfile.pp svneol=native#text/plain
 packages/fcl-web/src/base/httpdefs.pp svneol=native#text/plain
 packages/fcl-web/src/base/iniwebsession.pp svneol=native#text/plain
 packages/fcl-web/src/base/webpage.pp svneol=native#text/plain
@@ -2624,6 +2767,7 @@ packages/fpvectorial/src/avisocncgcodewriter.pas svneol=native#text/pascal
 packages/fpvectorial/src/avisozlib.pas svneol=native#text/pascal
 packages/fpvectorial/src/cdrvectorialreader.pas svneol=native#text/pascal
 packages/fpvectorial/src/dxfvectorialreader.pas svneol=native#text/pascal
+packages/fpvectorial/src/epsvectorialreader.pas svneol=native#text/pascal
 packages/fpvectorial/src/fpvectbuildunit.pas svneol=native#text/pascal
 packages/fpvectorial/src/fpvectorial.pas svneol=native#text/pascal
 packages/fpvectorial/src/fpvtocanvas.pas svneol=native#text/pascal
@@ -8024,6 +8168,7 @@ rtl/win32/gprt0.as svneol=native#text/plain
 rtl/win32/initc.pp svneol=native#text/plain
 rtl/win32/objinc.inc svneol=native#text/plain
 rtl/win32/signals.pp svneol=native#text/plain
+rtl/win32/sysinit.inc svneol=native#text/plain
 rtl/win32/sysinitcyg.pp svneol=native#text/plain
 rtl/win32/sysinitgprof.pp svneol=native#text/plain
 rtl/win32/sysinitpas.pp svneol=native#text/plain
@@ -8968,6 +9113,8 @@ tests/tbs/tb0571.pas svneol=native#text/plain
 tests/tbs/tb0572.pp svneol=native#text/plain
 tests/tbs/tb0573.pp svneol=native#text/plain
 tests/tbs/tb0574.pp svneol=native#text/pascal
+tests/tbs/tb0575.pp svneol=native#text/plain
+tests/tbs/tb0576.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
@@ -9491,6 +9638,20 @@ tests/test/cg/variants/tvarol96.pp svneol=native#text/plain
 tests/test/dumpclass.pp svneol=native#text/plain
 tests/test/dumpmethods.pp svneol=native#text/plain
 tests/test/lcpref.inc svneol=native#text/plain
+tests/test/library/testdll.pp svneol=native#text/plain
+tests/test/library/testdll2.pp svneol=native#text/plain
+tests/test/library/tlib1a.pp svneol=native#text/plain
+tests/test/library/tlib1a2.pp svneol=native#text/plain
+tests/test/library/tlib1b.pp svneol=native#text/plain
+tests/test/library/tlib2b.pp svneol=native#text/plain
+tests/test/library/tlib3a.pp svneol=native#text/plain
+tests/test/library/tlib3b.pp svneol=native#text/plain
+tests/test/library/tlib3c.pp svneol=native#text/plain
+tests/test/library/tlib3d.pp svneol=native#text/plain
+tests/test/library/ttdllexe.pp svneol=native#text/plain
+tests/test/library/ttdlltest.pp svneol=native#text/plain
+tests/test/library/ulib2a.pp svneol=native#text/plain
+tests/test/library/ulib2b.pp svneol=native#text/plain
 tests/test/opt/README.txt svneol=native#text/plain
 tests/test/opt/tarmshift.pp svneol=native#text/plain
 tests/test/opt/tcaseopt1.pp svneol=native#text/plain
@@ -9687,6 +9848,10 @@ tests/test/tchlp51.pp svneol=native#text/pascal
 tests/test/tchlp52.pp svneol=native#text/pascal
 tests/test/tchlp53.pp svneol=native#text/pascal
 tests/test/tchlp54.pp svneol=native#text/pascal
+tests/test/tchlp55.pp svneol=native#text/pascal
+tests/test/tchlp56.pp svneol=native#text/pascal
+tests/test/tchlp57.pp svneol=native#text/pascal
+tests/test/tchlp58.pp svneol=native#text/pascal
 tests/test/tchlp6.pp svneol=native#text/pascal
 tests/test/tchlp7.pp svneol=native#text/pascal
 tests/test/tchlp8.pp svneol=native#text/pascal
@@ -9915,6 +10080,7 @@ tests/test/thlp41.pp svneol=native#text/pascal
 tests/test/thlp42.pp svneol=native#text/pascal
 tests/test/thlp43.pp svneol=native#text/pascal
 tests/test/thlp44.pp svneol=native#text/pascal
+tests/test/thlp45.pp svneol=native#text/pascal
 tests/test/thlp5.pp svneol=native#text/pascal
 tests/test/thlp6.pp svneol=native#text/pascal
 tests/test/thlp7.pp svneol=native#text/pascal
@@ -9964,6 +10130,8 @@ tests/test/tisogoto3.pp svneol=native#text/pascal
 tests/test/tisogoto4.pp svneol=native#text/pascal
 tests/test/tlib1a.pp svneol=native#text/plain
 tests/test/tlib1b.pp svneol=native#text/plain
+tests/test/tlib2a.pp svneol=native#text/plain
+tests/test/tlib2b.pp svneol=native#text/plain
 tests/test/tlibrary1.pp svneol=native#text/plain
 tests/test/tlibrary2.pp svneol=native#text/plain
 tests/test/tlibrary3.pp svneol=native#text/plain
@@ -10222,6 +10390,8 @@ tests/test/trhlp39.pp svneol=native#text/pascal
 tests/test/trhlp4.pp svneol=native#text/pascal
 tests/test/trhlp40.pp svneol=native#text/pascal
 tests/test/trhlp41.pp svneol=native#text/pascal
+tests/test/trhlp42.pp svneol=native#text/pascal
+tests/test/trhlp43.pp svneol=native#text/pascal
 tests/test/trhlp5.pp svneol=native#text/pascal
 tests/test/trhlp6.pp svneol=native#text/pascal
 tests/test/trhlp7.pp svneol=native#text/pascal
@@ -10229,6 +10399,9 @@ tests/test/trhlp8.pp svneol=native#text/pascal
 tests/test/trhlp9.pp svneol=native#text/pascal
 tests/test/trox1.pp svneol=native#text/plain
 tests/test/trox2.pp svneol=native#text/plain
+tests/test/trox3.pp svneol=native#text/pascal
+tests/test/trox4.pp svneol=native#text/pascal
+tests/test/trox5.pp svneol=native#text/pascal
 tests/test/trstr1.pp svneol=native#text/plain
 tests/test/trstr2.pp svneol=native#text/plain
 tests/test/trstr3.pp svneol=native#text/plain
@@ -10316,6 +10489,7 @@ tests/test/tutf82.pp svneol=native#text/plain
 tests/test/tvarpropsetter1.pp svneol=native#text/plain
 tests/test/tvarpropsetter2.pp svneol=native#text/plain
 tests/test/tvarset1.pp svneol=native#text/plain
+tests/test/twarn1.pp svneol=native#text/pascal
 tests/test/tweaklib1.pp svneol=native#text/plain
 tests/test/tweaklib2.pp svneol=native#text/plain
 tests/test/tweaklib3.pp svneol=native#text/plain
@@ -10356,6 +10530,7 @@ tests/test/uimpluni1.pp svneol=native#text/plain
 tests/test/uimpluni2.pp svneol=native#text/plain
 tests/test/uinline4a.pp svneol=native#text/plain
 tests/test/uinline4b.pp svneol=native#text/plain
+tests/test/ulib2a.pp svneol=native#text/plain
 tests/test/umaclocalprocparam3f.pp svneol=native#text/plain
 tests/test/umacpas1.pp svneol=native#text/plain
 tests/test/umainnam.pp svneol=native#text/plain
@@ -10685,6 +10860,7 @@ tests/webtbf/tw1905.pp svneol=native#text/plain
 tests/webtbf/tw1927.pp svneol=native#text/plain
 tests/webtbf/tw1928.pp svneol=native#text/plain
 tests/webtbf/tw1939.pp svneol=native#text/plain
+tests/webtbf/tw19463.pp svneol=native#text/pascal
 tests/webtbf/tw1949.pp svneol=native#text/plain
 tests/webtbf/tw1969.pp svneol=native#text/plain
 tests/webtbf/tw1995.pp svneol=native#text/plain
@@ -11531,6 +11707,7 @@ tests/webtbs/tw1936.pp svneol=native#text/plain
 tests/webtbs/tw1938.pp svneol=native#text/plain
 tests/webtbs/tw1948.pp svneol=native#text/plain
 tests/webtbs/tw1950.pp svneol=native#text/plain
+tests/webtbs/tw19548.pp svneol=native#text/pascal
 tests/webtbs/tw1964.pp svneol=native#text/plain
 tests/webtbs/tw1996.pp svneol=native#text/plain
 tests/webtbs/tw2001.pp svneol=native#text/plain
@@ -12353,6 +12530,7 @@ tests/webtbs/uw18087a.pp svneol=native#text/pascal
 tests/webtbs/uw18087b.pp svneol=native#text/pascal
 tests/webtbs/uw18909a.pp svneol=native#text/pascal
 tests/webtbs/uw18909b.pp svneol=native#text/pascal
+tests/webtbs/uw19159.pp svneol=native#text/pascal
 tests/webtbs/uw2004.inc svneol=native#text/plain
 tests/webtbs/uw2040.pp svneol=native#text/plain
 tests/webtbs/uw2266a.inc svneol=native#text/plain

+ 20 - 22
Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/05/19]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/06/05]
 #
 default: help
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -107,37 +107,25 @@ FPC=$(PP)
 endif
 endif
 ifndef FPC
-DETERMINE_NATIVE_COMPILER=1
-else
-ifdef CROSSCOMPILE
-ifndef FPCFPMAKE
-DETERMINE_NATIVE_COMPILER=1
-endif
-endif
-endif
-ifdef DETERMINE_NATIVE_COMPILER
 FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
 ifneq ($(FPCPROG),)
 FPCPROG:=$(firstword $(FPCPROG))
 ifneq ($(CPU_TARGET),)
-FPCNATIVE:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
 else
-FPCNATIVE:=$(shell $(FPCPROG) -PB)
+FPC:=$(shell $(FPCPROG) -PB)
 endif
-ifneq ($(findstring Error,$(FPCNATIVE)),)
-override FPCNATIVE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 else
-ifeq ($(strip $(wildcard $(FPCNATIVE))),)
-FPCNATIVE:=$(firstword $(FPCPROG))
+ifeq ($(strip $(wildcard $(FPC))),)
+FPC:=$(firstword $(FPCPROG))
 endif
 endif
 else
-override FPCNATIVE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 endif
 endif
-ifndef FPC
-FPC=$(FPCNATIVE)
-endif
 override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
 override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
 FOUNDFPC:=$(strip $(wildcard $(FPC)))
@@ -279,14 +267,24 @@ PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(F
 ifndef FPCFPMAKE
 ifdef CROSSCOMPILE
 ifeq ($(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR)))),)
-FPCFPMAKE:=$(FPCNATIVE)
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPCFPMAKE:=$(shell $(FPCPROG) -PB)
+ifeq ($(strip $(wildcard $(FPCFPMAKE))),)
+FPCFPMAKE:=$(firstword $(FPCPROG))
+endif
+else
+override FPCFPMAKE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
 else
 FPCFPMAKE=$(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR))))
+FPMAKE_SKIP_CONFIG=-n
 export FPCFPMAKE
+export FPMAKE_SKIP_CONFIG
 endif
 else
 FPCFPMAKE=$(FPC)
-export FPCFPMAKE
 endif
 endif
 override PACKAGE_NAME=fpc

+ 82 - 35
compiler/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/04/24]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/07/01]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -107,42 +107,23 @@ FPC=$(PP)
 endif
 endif
 ifndef FPC
-DETERMINE_NATIVE_COMPILER=1
-else
-ifdef CROSSCOMPILE
-ifndef FPCFPMAKE
-DETERMINE_NATIVE_COMPILER=1
-endif
-endif
-endif
-ifdef DETERMINE_NATIVE_COMPILER
 FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
 ifneq ($(FPCPROG),)
 FPCPROG:=$(firstword $(FPCPROG))
 ifneq ($(CPU_TARGET),)
-FPCNATIVE:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
+FPC:=$(shell $(FPCPROG) -P$(CPU_TARGET) -PB)
 else
-FPCNATIVE:=$(shell $(FPCPROG) -PB)
+FPC:=$(shell $(FPCPROG) -PB)
 endif
-ifneq ($(findstring Error,$(FPCNATIVE)),)
-override FPCNATIVE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 else
-ifeq ($(strip $(wildcard $(FPCNATIVE))),)
-FPCNATIVE:=$(firstword $(FPCPROG))
+ifeq ($(strip $(wildcard $(FPC))),)
+FPC:=$(firstword $(FPCPROG))
 endif
 endif
 else
-override FPCNATIVE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
-endif
-endif
-ifndef FPC
-FPC=$(FPCNATIVE)
-endif
-ifndef FPCFPMAKE
-ifdef CROSSOMPILE
-FPCFPMAKE=$(FPCNATIVE)
-else
-FPCFPMAKE=$(FPC)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
 endif
 endif
 override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
@@ -160,7 +141,7 @@ endif
 ifndef FPC_VERSION
 FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
 endif
-export FPC FPCFPMAKE FPC_VERSION FPC_COMPILERINFO
+export FPC FPC_VERSION FPC_COMPILERINFO
 unexport CHECKDEPEND ALLDEPENDENCIES
 ifndef CPU_TARGET
 ifdef CPU_TARGET_DEFAULT
@@ -283,6 +264,29 @@ ifeq ($(UNITSDIR),)
 UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+ifndef FPCFPMAKE
+ifdef CROSSCOMPILE
+ifeq ($(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR)))),)
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPCFPMAKE:=$(shell $(FPCPROG) -PB)
+ifeq ($(strip $(wildcard $(FPCFPMAKE))),)
+FPCFPMAKE:=$(firstword $(FPCPROG))
+endif
+else
+override FPCFPMAKE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+FPCFPMAKE=$(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR))))
+FPMAKE_SKIP_CONFIG=-n
+export FPCFPMAKE
+export FPMAKE_SKIP_CONFIG
+endif
+else
+FPCFPMAKE=$(FPC)
+endif
+endif
 override PACKAGE_NAME=compiler
 override PACKAGE_VERSION=2.5.1
 unexport FPC_VERSION FPC_COMPILERINFO
@@ -2543,6 +2547,15 @@ UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
 else
 UNITDIR_RTL=$(PACKAGEDIR_RTL)
 endif
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)
+endif
+endif
 ifdef CHECKDEPEND
 $(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
 	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
@@ -2560,6 +2573,9 @@ endif
 ifdef UNITDIR_RTL
 override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
+ifdef UNITDIR_FPMAKE_RTL
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_RTL)
+endif
 endif
 ifndef NOCPUDEF
 override FPCOPTDEF=$(ARCH)
@@ -2672,7 +2688,7 @@ override FPCOPT+=-Aas
 endif
 endif
 ifeq ($(findstring 2.0.,$(FPC_VERSION)),)
-ifeq ($(OS_TARGET),linux)
+ifneq ($(findstring $(OS_TARGET),linux solaris),)
 ifeq ($(CPU_TARGET),x86_64)
 override FPCOPT+=-Cg
 endif
@@ -3505,15 +3521,20 @@ msgtxt.inc: $(MSGFILE)
 msg: msgtxt.inc
 insdatx86 : $(COMPILER_UNITTARGETDIR) x86/x86ins.dat
 	$(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86ins.pp
-	cd x86 && ../utils/mkx86ins$(SRCEXEEXT) && mv -f *.inc ../i386
-	cd x86 && ../utils/mkx86ins$(SRCEXEEXT) x86_64 && mv -f *.inc ../x86_64
+	cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) && mv -f *.inc ../i386
+	cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) x86_64 && mv -f *.inc ../x86_64
+	$(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86reg.pp
+	cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT)
+	mv -f x86/r386*.inc i386
+	cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT) x86_64
+	mv -f x86/r8664*.inc x86_64
 insdatarm : arm/armins.dat
 	    $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmins.pp
-	cd arm && ../utils/mkarmins$(SRCEXEEXT)
+	cd arm && ..$(PATHSEP)utils$(PATHSEP)mkarmins$(SRCEXEEXT)
 insdat: insdatx86 insdatarm
 regdatarm : arm/armreg.dat
 	    $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmreg.pp
-	cd arm && ../utils/mkarmreg$(SRCEXEEXT)
+	cd arm && ..$(PATHSEP)utils$PATHSEP)mkarmreg$(SRCEXEEXT)
 revision.inc :
 ifneq ($(REVSTR),)
 ifdef USEZIPWRAPPER
@@ -3534,7 +3555,8 @@ revision :
 	$(MAKE) revision.inc
 $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg \
 	     $(wildcard systems/*.pas) $(wilcard systems/*.inc) \
-	     $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc)
+	     $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc) \
+	     $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR)
 ifneq ($(REVSTR),)
 ifdef USEZIPWRAPPER
 ifneq ($(ECHOREDIR),echo)
@@ -3626,8 +3648,8 @@ endif
 endif
 endif
 else
+cycle: override FPC=
 cycle:
-override FPC=
 	$(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
 	$(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler
 	$(MAKE) 'FPC=$(BASEDIR)/$(TEMPNAME)' OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
@@ -3689,6 +3711,31 @@ rtlclean:
 	$(MAKE) -C $(PACKAGEDIR_RTL) clean
 rtlinstall:
 	$(MAKE) -C $(PACKAGEDIR_RTL) install
+PPUDIR=$(COMPILER_UNITTARGETDIR)
+ALLPPUDIR=$(CPU_TARGET)/units/*
+PPULIST=$(wildcard $(PPUDIR)/*.ppu)
+PPULOGLIST=$(subst .ppu,.log-ppu,$(PPULIST))
+RTLPPUDIR=../rtl/units/$(FULL_TARGET)
+RTLPPULIST=$(wildcard $(RTLPPUDIR)/*.ppu)
+RTLPPULOGLIST=$(subst .ppu,.log-ppu,$(RTLPPULIST))
+.PHONY : ppulogs cleanppulogs rtlppulogs cleanrtlppulogs testppudump
+ppulogs : $(PPULOGLIST)
+rtlppulogs : $(RTLPPULOGLIST)
+vpath %.ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
+vpath %.log-ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
+%.log-ppu : %.ppu ./utils/ppudump$(EXEEXT)
+	.$(PATHSEP)utils$(PATHSEP)ppudump -VA -M $< > $@
+./utils/ppudump$(EXEEXT):
+	$(MAKE) -C $(COMPILERUTILSDIR) ppudump$(EXEEXT)
+ppuinfo :
+	echo PPU list is "$(PPULIST)"
+	echo PPULOG list is "$(PPULOGLIST)"
+cleanppulogs :
+	-$(RMPROG) $(PPULOGLIST)
+cleanrtlppulogs :
+	-$(RMPROG) $(RTLPPULOGLIST)
+testppudump :
+	$(MAKE) cleanrtlppulogs cleanppulogs ppulogs rtlppulogs
 localmake:=$(strip $(wildcard makefile.loc))
 ifdef localmake
 include ./$(localmake)

+ 53 - 6
compiler/Makefile.fpc

@@ -397,18 +397,23 @@ msg: msgtxt.inc
 
 insdatx86 : $(COMPILER_UNITTARGETDIR) x86/x86ins.dat
 	$(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86ins.pp
-        cd x86 && ../utils/mkx86ins$(SRCEXEEXT) && mv -f *.inc ../i386
-        cd x86 && ../utils/mkx86ins$(SRCEXEEXT) x86_64 && mv -f *.inc ../x86_64
+        cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) && mv -f *.inc ../i386
+        cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86ins$(SRCEXEEXT) x86_64 && mv -f *.inc ../x86_64
+	$(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkx86reg.pp
+        cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT)
+        mv -f x86/r386*.inc i386
+        cd x86 && ..$(PATHSEP)utils$(PATHSEP)mkx86reg$(SRCEXEEXT) x86_64
+        mv -f x86/r8664*.inc x86_64
 
 insdatarm : arm/armins.dat
 	    $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmins.pp
-        cd arm && ../utils/mkarmins$(SRCEXEEXT)
+        cd arm && ..$(PATHSEP)utils$(PATHSEP)mkarmins$(SRCEXEEXT)
 
 insdat: insdatx86 insdatarm
 
 regdatarm : arm/armreg.dat
 	    $(COMPILER) -FE$(COMPILERUTILSDIR) $(COMPILERUTILSDIR)/mkarmreg.pp
-        cd arm && ../utils/mkarmreg$(SRCEXEEXT)
+        cd arm && ..$(PATHSEP)utils$PATHSEP)mkarmreg$(SRCEXEEXT)
 
 # revision.inc rule
 revision.inc :
@@ -436,7 +441,8 @@ revision :
 # ECHOREDIR sometimes does not remove double quotes
 $(EXENAME) : $(wildcard *.pas) $(wildcard *.inc) msg \
              $(wildcard systems/*.pas) $(wilcard systems/*.inc) \
-             $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc)
+             $(wildcard $(CPC_TARGET)/*.pas) $(wildcard $(CPC_TARGET)/*.inc) \
+             $(COMPILER_UNITTARGETDIR) $(COMPILER_TARGETDIR)
 ifneq ($(REVSTR),)
 ifdef USEZIPWRAPPER
 ifneq ($(ECHOREDIR),echo)
@@ -584,10 +590,10 @@ else
 # ppc3/ppcXXX = native (skipped for cross installation)
 #
 
+cycle: override FPC=
 cycle:
 # ppc (source native)
 # Clear detected compiler binary, because it can be existing crosscompiler binary, but we need native compiler here
-override FPC=
         $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 rtlclean rtl
         $(MAKE) OS_TARGET=$(OS_SOURCE) CPU_TARGET=$(CPU_SOURCE) EXENAME=$(TEMPNAME) CROSSBINDIR= BINUTILSPREFIX= CROSSCYCLEBOOTSTRAP=1 cycleclean compiler
 # ppcross<ARCH> (source native)
@@ -699,6 +705,47 @@ rtlclean:
 rtlinstall:
         $(MAKE) -C $(PACKAGEDIR_RTL) install
 
+#####################################################################
+# PPU testing targets
+#####################################################################
+
+PPUDIR=$(COMPILER_UNITTARGETDIR)
+ALLPPUDIR=$(CPU_TARGET)/units/*
+PPULIST=$(wildcard $(PPUDIR)/*.ppu)
+PPULOGLIST=$(subst .ppu,.log-ppu,$(PPULIST))
+
+RTLPPUDIR=../rtl/units/$(FULL_TARGET)
+RTLPPULIST=$(wildcard $(RTLPPUDIR)/*.ppu)
+RTLPPULOGLIST=$(subst .ppu,.log-ppu,$(RTLPPULIST))
+
+.PHONY : ppulogs cleanppulogs rtlppulogs cleanrtlppulogs testppudump
+
+ppulogs : $(PPULOGLIST)
+
+rtlppulogs : $(RTLPPULOGLIST)
+
+vpath %.ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
+vpath %.log-ppu $(PPUDIR) $(RTLPPUDIR) $(ALLPPUDIR)
+
+%.log-ppu : %.ppu ./utils/ppudump$(EXEEXT)
+	.$(PATHSEP)utils$(PATHSEP)ppudump -VA -M $< > $@
+
+
+./utils/ppudump$(EXEEXT):
+	$(MAKE) -C $(COMPILERUTILSDIR) ppudump$(EXEEXT)
+
+ppuinfo :
+	echo PPU list is "$(PPULIST)"
+	echo PPULOG list is "$(PPULOGLIST)"
+
+cleanppulogs :
+	-$(RMPROG) $(PPULOGLIST)
+
+cleanrtlppulogs :
+	-$(RMPROG) $(RTLPPULOGLIST)
+
+testppudump :
+	$(MAKE) cleanrtlppulogs cleanppulogs ppulogs rtlppulogs
 
 #####################################################################
 # local user configurable file

+ 5 - 3
compiler/aasmdata.pas

@@ -71,8 +71,8 @@ interface
         al_end
       );
 
-      { Type of constant 'pools'. Currently contains only string types,
-        but may be extended with reals, sets, etc. }
+      { Type of constant 'pools'. Mostly for string types, but usable for
+        floating point and large set constants, too. }
       
       TConstPoolType = (
          sp_invalid,
@@ -87,7 +87,9 @@ interface
          sp_objcclassnames,
          sp_objcvarnames,
          sp_objcvartypes,
-         sp_objcprotocolrefs
+         sp_objcprotocolrefs,
+         sp_varsets,
+         sp_floats
       );
       
     const

+ 73 - 86
compiler/aggas.pas

@@ -45,6 +45,7 @@ interface
       TGNUAssembler=class(texternalassembler)
       protected
         function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;virtual;
+        function sectionattrs_coff(atype:TAsmSectiontype):string;virtual;
         procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder);
         procedure WriteExtraHeader;virtual;
         procedure WriteInstruction(hp: tai);
@@ -121,25 +122,6 @@ implementation
 {                          Support routines                                  }
 {****************************************************************************}
 
-   function fixline(s:string):string;
-   {
-     return s with all leading and ending spaces and tabs removed
-   }
-     var
-       i,j,k : integer;
-     begin
-       i:=length(s);
-       while (i>0) and (s[i] in [#9,' ']) do
-        dec(i);
-       j:=1;
-       while (j<i) and (s[j] in [#9,' ']) do
-        inc(j);
-       for k:=j to i do
-        if s[k] in [#0..#31,#127..#255] then
-         s[k]:='.';
-       fixline:=Copy(s,j,i-j+1);
-     end;
-
     function single2str(d : single) : string;
       var
          hs : string;
@@ -257,6 +239,19 @@ implementation
         result := target_asm.labelprefix+'$set$'+tostr(setcount);
       end;
 
+    function is_smart_section(atype:TAsmSectiontype):boolean;
+      begin
+        { For bss we need to set some flags that are target dependent,
+          it is easier to disable it for smartlinking. It doesn't take up
+          filespace }
+        result:=not(target_info.system in systems_darwin) and
+           create_smartlink_sections and
+           (atype<>sec_toc) and
+           (atype<>sec_user) and
+           { on embedded systems every byte counts, so smartlink bss too }
+           ((atype<>sec_bss) or (target_info.system in systems_embedded));
+      end;
+
     function TGNUAssembler.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
       const
         secnames : array[TAsmSectiontype] of string[length('__DATA, __datacoal_nt,coalesced')] = ('','',
@@ -423,16 +418,7 @@ implementation
         if atype=sec_user then
           secname:=aname;
 
-        { For bss we need to set some flags that are target dependent,
-          it is easier to disable it for smartlinking. It doesn't take up
-          filespace }
-        if not(target_info.system in systems_darwin) and
-           create_smartlink_sections and
-           (aname<>'') and
-           (atype<>sec_toc) and
-           (atype<>sec_user) and
-           { on embedded systems every byte counts, so smartlink bss too }
-           ((atype<>sec_bss) or (target_info.system in systems_embedded)) then
+        if is_smart_section(atype) and (aname<>'') then
           begin
             case aorder of
               secorder_begin :
@@ -449,6 +435,45 @@ implementation
       end;
 
 
+    function TGNUAssembler.sectionattrs_coff(atype:TAsmSectiontype):string;
+      begin
+        case atype of
+          sec_code, sec_init, sec_fini, sec_stub:
+            result:='x';
+
+          { TODO: must be individual for each section }
+          sec_user:
+            result:='d';
+
+          sec_data, sec_data_lazy, sec_data_nonlazy, sec_fpc,
+          sec_idata2, sec_idata4, sec_idata5, sec_idata6, sec_idata7:
+            result:='d';
+
+          { TODO: these need a fix to become read-only }
+          sec_rodata, sec_rodata_norel:
+            result:='d';
+
+          sec_bss:
+            result:='b';
+
+          { TODO: Somewhat questionable. FPC does not allow initialized threadvars,
+            so no sense to mark it as containing data. But Windows allows it to
+            contain data, and Linux even has .tdata and .tbss }
+          sec_threadvar:
+            result:='b';
+
+          sec_pdata, sec_edata, sec_eh_frame, sec_toc:
+            result:='r';
+
+          sec_stab,sec_stabstr,
+          sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev:
+            result:='n';
+        else
+          result:='';  { defaults to data+load }
+        end;
+      end;
+
+
     procedure TGNUAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder);
       var
         s : string;
@@ -503,6 +528,20 @@ implementation
                   internalerror(2006031101);
               end;
             end;
+        else
+          { GNU AS won't recognize '.text.n_something' section name as belonging
+            to '.text' and assigns default attributes to it, which is not
+            always correct. We have to fix it.
+
+            TODO: This likely applies to all systems which smartlink without
+            creating libraries }
+          if (target_info.system in [system_i386_win32,system_x86_64_win64]) and
+            is_smart_section(atype) and (aname<>'') then
+            begin
+              s:=sectionattrs_coff(atype);
+              if (s<>'') then
+                AsmWrite(',"'+s+'"');
+            end;
         end;
         AsmLn;
         LastSecType:=atype;
@@ -587,7 +626,6 @@ implementation
     var
       ch       : char;
       hp       : tai;
-      hp1      : tailineinfo;
       constdef : taiconst_type;
       s,t      : string;
       i,pos,l  : longint;
@@ -618,52 +656,10 @@ implementation
          prefetch(pointer(hp.next)^);
          if not(hp.typ in SkipLineInfo) then
           begin
-            hp1 := hp as tailineinfo;
-            current_filepos:=hp1.fileinfo;
-             { no line info for inlined code }
-             if do_line and (inlinelevel=0) then
-              begin
-                { load infile }
-                if lastfileinfo.fileindex<>hp1.fileinfo.fileindex then
-                 begin
-                   infile:=current_module.sourcefiles.get_file(hp1.fileinfo.fileindex);
-                   if assigned(infile) then
-                    begin
-                      { open only if needed !! }
-                      if (cs_asm_source in current_settings.globalswitches) then
-                       infile.open;
-                    end;
-                   { avoid unnecessary reopens of the same file !! }
-                   lastfileinfo.fileindex:=hp1.fileinfo.fileindex;
-                   { be sure to change line !! }
-                   lastfileinfo.line:=-1;
-                 end;
-              { write source }
-                if (cs_asm_source in current_settings.globalswitches) and
-                   assigned(infile) then
-                 begin
-                   if (infile<>lastinfile) then
-                     begin
-                       AsmWriteLn(target_asm.comment+'['+infile.name^+']');
-                       if assigned(lastinfile) then
-                         lastinfile.close;
-                     end;
-                   if (hp1.fileinfo.line<>lastfileinfo.line) and
-                      ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
-                     begin
-                       if (hp1.fileinfo.line<>0) and
-                          ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
-                         AsmWriteLn(target_asm.comment+'['+tostr(hp1.fileinfo.line)+'] '+
-                           fixline(infile.GetLineStr(hp1.fileinfo.line)));
-                       { set it to a negative value !
-                       to make that is has been read already !! PM }
-                       if (infile.linebuf^[hp1.fileinfo.line]>=0) then
-                         infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
-                     end;
-                 end;
-                lastfileinfo:=hp1.fileinfo;
-                lastinfile:=infile;
-              end;
+            current_filepos:=tailineinfo(hp).fileinfo;
+            { no line info for inlined code }
+            if do_line and (inlinelevel=0) then
+              WriteSourceLine(hp as tailineinfo);
           end;
 
          case hp.typ of
@@ -697,16 +693,7 @@ implementation
            ait_tempalloc :
              begin
                if (cs_asm_tempalloc in current_settings.globalswitches) then
-                 begin
-{$ifdef EXTDEBUG}
-                   if assigned(tai_tempalloc(hp).problem) then
-                     AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+
-                       tostr(tai_tempalloc(hp).tempsize)+' '+tai_tempalloc(hp).problem^)
-                   else
-{$endif EXTDEBUG}
-                     AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+
-                       tostr(tai_tempalloc(hp).tempsize)+' '+tempallocstr[tai_tempalloc(hp).allocation]);
-                 end;
+                 WriteTempalloc(tai_tempalloc(hp));
              end;
 
            ait_align :

+ 2 - 1
compiler/arm/cgcpu.pas

@@ -2084,7 +2084,8 @@ unit cgcpu;
 
               if not((def.typ=pointerdef) or
                     ((def.typ=orddef) and
-                     (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,pasbool]))) then
+                     (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,
+                                               pasbool8,pasbool16,pasbool32,pasbool64]))) then
                  ai.SetCondition(C_VC)
               else
                 if TAiCpu(List.Last).opcode in [A_RSB,A_RSC,A_SBC,A_SUB] then

+ 1 - 1
compiler/arm/narmcnv.pas

@@ -171,7 +171,7 @@ implementation
                         cg.a_jmp_flags(current_asmdata.CurrAsmList,F_GE,l2);
 
                         hregister:=cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64);
-                        current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(8)));
+                        new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,l1.name,const_align(8));
                         current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
                         { I got this constant from a test program (FK) }
                         current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($41f00000));

+ 77 - 2
compiler/assemble.pas

@@ -37,7 +37,7 @@ interface
 
     const
        { maximum of aasmoutput lists there will be }
-       maxoutputlists = 20;
+       maxoutputlists = ord(high(tasmlisttype))+1;
        { buffer size for writing the .s file }
        AsmOutSize=32768*4;
 
@@ -81,6 +81,8 @@ interface
         lastinfile   : tinputfile;
       {last section type written}
         lastsectype : TAsmSectionType;
+        procedure WriteSourceLine(hp: tailineinfo);
+        procedure WriteTempalloc(hp: tai_tempalloc);
       public
         {# Returns the complete path and executable name of the assembler
            program.
@@ -189,6 +191,24 @@ Implementation
     var
       CAssembler : array[tasm] of TAssemblerClass;
 
+    function fixline(s:string):string;
+     {
+       return s with all leading and ending spaces and tabs removed
+     }
+      var
+        i,j,k : integer;
+      begin
+        i:=length(s);
+        while (i>0) and (s[i] in [#9,' ']) do
+          dec(i);
+        j:=1;
+        while (j<i) and (s[j] in [#9,' ']) do
+          inc(j);
+        for k:=j to i do
+          if s[k] in [#0..#31,#127..#255] then
+            s[k]:='.';
+        fixline:=Copy(s,j,i-j+1);
+      end;
 
 {*****************************************************************************
                                    TAssembler
@@ -250,7 +270,7 @@ Implementation
     Function DoPipe:boolean;
       begin
         DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
-                (([cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) and
+                (([cs_asm_extern,cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) and
                 ((target_asm.id in [as_gas,as_ggas,as_darwin]));
       end;
 
@@ -603,6 +623,61 @@ Implementation
          end;
       end;
 
+    procedure TExternalAssembler.WriteSourceLine(hp: tailineinfo);
+      begin
+        { load infile }
+        if lastfileinfo.fileindex<>hp.fileinfo.fileindex then
+          begin
+            infile:=current_module.sourcefiles.get_file(hp.fileinfo.fileindex);
+            if assigned(infile) then
+              begin
+                { open only if needed !! }
+                if (cs_asm_source in current_settings.globalswitches) then
+                  infile.open;
+              end;
+            { avoid unnecessary reopens of the same file !! }
+            lastfileinfo.fileindex:=hp.fileinfo.fileindex;
+            { be sure to change line !! }
+            lastfileinfo.line:=-1;
+          end;
+        { write source }
+        if (cs_asm_source in current_settings.globalswitches) and
+          assigned(infile) then
+          begin
+            if (infile<>lastinfile) then
+              begin
+                AsmWriteLn(target_asm.comment+'['+infile.name^+']');
+                if assigned(lastinfile) then
+                  lastinfile.close;
+              end;
+            if (hp.fileinfo.line<>lastfileinfo.line) and
+              (hp.fileinfo.line<infile.maxlinebuf) then
+              begin
+                if (hp.fileinfo.line<>0) and
+                  (infile.linebuf^[hp.fileinfo.line]>=0) then
+                  AsmWriteLn(target_asm.comment+'['+tostr(hp.fileinfo.line)+'] '+
+                  fixline(infile.GetLineStr(hp.fileinfo.line)));
+                { set it to a negative value !
+                  to make that is has been read already !! PM }
+                if (infile.linebuf^[hp.fileinfo.line]>=0) then
+                  infile.linebuf^[hp.fileinfo.line]:=-infile.linebuf^[hp.fileinfo.line]-1;
+              end;
+          end;
+        lastfileinfo:=hp.fileinfo;
+        lastinfile:=infile;
+      end;
+
+    procedure TExternalAssembler.WriteTempalloc(hp: tai_tempalloc);
+      begin
+{$ifdef EXTDEBUG}
+        if assigned(hp.problem) then
+          AsmWriteLn(target_asm.comment+'Temp '+tostr(hp.temppos)+','+
+          tostr(hp.tempsize)+' '+hp.problem^)
+        else
+{$endif EXTDEBUG}
+          AsmWriteLn(target_asm.comment+'Temp '+tostr(hp.temppos)+','+
+            tostr(hp.tempsize)+' '+tempallocstr[hp.allocation]);
+      end;
 
     procedure TExternalAssembler.WriteTree(p:TAsmList);
       begin

+ 21 - 11
compiler/avr/cgcpu.pas

@@ -118,7 +118,7 @@ unit cgcpu;
        globals,verbose,systems,cutils,
        fmodule,
        symconst,symsym,
-       tgobj,
+       tgobj,rgobj,
        procinfo,cpupi,
        paramgr;
 
@@ -594,6 +594,14 @@ unit cgcpu;
 
 
     function tcgavr.normalize_ref(list:TAsmList;ref: treference;tmpreg : tregister) : treference;
+
+      procedure maybegetcpuregister(list:tasmlist;reg : tregister);
+        begin
+          { allocate the register only, if a cpu register is passed }
+          if getsupreg(reg)<first_int_imreg then
+            getcpuregister(list,reg);
+        end;
+
       var
         tmpref : treference;
         l : tasmlabel;
@@ -618,10 +626,10 @@ unit cgcpu;
             tmpref.symbol:=ref.symbol;
             tmpref.offset:=ref.offset;
             tmpref.refaddr:=addr_lo8;
-            getcpuregister(list,tmpreg);
+            maybegetcpuregister(list,tmpreg);
             list.concat(taicpu.op_reg_ref(A_LDI,tmpreg,tmpref));
             tmpref.refaddr:=addr_hi8;
-            getcpuregister(list,GetNextReg(tmpreg));
+            maybegetcpuregister(list,GetNextReg(tmpreg));
             list.concat(taicpu.op_reg_ref(A_LDI,GetNextReg(tmpreg),tmpref));
             if (ref.base<>NR_NO) then
               begin
@@ -640,9 +648,9 @@ unit cgcpu;
           end
         else if (ref.base<>NR_NO) and (ref.index<>NR_NO) then
           begin
-            getcpuregister(list,tmpreg);
+            maybegetcpuregister(list,tmpreg);
             emit_mov(list,tmpreg,ref.index);
-            getcpuregister(list,GetNextReg(tmpreg));
+            maybegetcpuregister(list,GetNextReg(tmpreg));
             emit_mov(list,GetNextReg(tmpreg),GetNextReg(ref.index));
             list.concat(taicpu.op_reg_reg(A_ADD,tmpreg,ref.base));
             list.concat(taicpu.op_reg_reg(A_ADC,GetNextReg(tmpreg),GetNextReg(ref.base)));
@@ -651,18 +659,18 @@ unit cgcpu;
           end
         else if (ref.base<>NR_NO) then
           begin
-            getcpuregister(list,tmpreg);
+            maybegetcpuregister(list,tmpreg);
             emit_mov(list,tmpreg,ref.base);
-            getcpuregister(list,GetNextReg(tmpreg));
+            maybegetcpuregister(list,GetNextReg(tmpreg));
             emit_mov(list,GetNextReg(tmpreg),GetNextReg(ref.base));
             ref.base:=tmpreg;
             ref.index:=NR_NO;
           end
         else if (ref.index<>NR_NO) then
           begin
-            getcpuregister(list,tmpreg);
+            maybegetcpuregister(list,tmpreg);
             emit_mov(list,tmpreg,ref.index);
-            getcpuregister(list,GetNextReg(tmpreg));
+            maybegetcpuregister(list,GetNextReg(tmpreg));
             emit_mov(list,GetNextReg(tmpreg),GetNextReg(ref.index));
             ref.base:=tmpreg;
             ref.index:=NR_NO;
@@ -1486,7 +1494,7 @@ unit cgcpu;
                    (source.symbol=nil) and
                    ((source.base=NR_R28) or
                     (source.base=NR_R29)) and
-                    (source.Index=NR_No) and
+                    (source.Index=NR_NO) and
                     (source.Offset in [0..64-len])) and
               not((source.Base=NR_NO) and (source.Index=NR_NO)) then
               srcref:=normalize_ref(list,source,NR_R30)
@@ -1517,6 +1525,7 @@ unit cgcpu;
                     list.concat(taicpu.op_reg(A_PUSH,GetNextReg(tmpreg)));
                     list.concat(taicpu.op_reg(A_POP,NR_R27));
                     list.concat(taicpu.op_reg(A_POP,NR_R26));
+                    dstref.base:=NR_R26;
                   end
                 else
                   dstref:=normalize_ref(list,dest,NR_R30);
@@ -1567,7 +1576,8 @@ unit cgcpu;
         current_asmdata.getjumplabel(hl);
         if not ((def.typ=pointerdef) or
                ((def.typ=orddef) and
-                (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,pasbool]))) then
+                (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,
+                                          pasbool8,pasbool16,pasbool32,pasbool64]))) then
           cond:=C_VC
         else
           cond:=C_CC;

+ 5 - 2
compiler/avr/cpubase.pas

@@ -458,10 +458,13 @@ unit cpubase;
 
 
     function dwarf_reg(r:tregister):byte;
+      var
+        reg : shortint;
       begin
-        result:=regdwarf_table[findreg_by_number(r)];
-        if result=-1 then
+        reg:=regdwarf_table[findreg_by_number(r)];
+        if reg=-1 then
           internalerror(200603251);
+        result:=reg;
       end;
 
 

+ 6 - 16
compiler/cclasses.pas

@@ -1089,10 +1089,8 @@ end;
       Var
         p,pmax : pchar;
       begin
-{$ifopt Q+}
-{$define overflowon}
-{$Q-}
-{$endif}
+{$push}
+{$q-,r-}
         result:=0;
         p:=@s[1];
         pmax:=@s[length(s)+1];
@@ -1101,20 +1099,15 @@ end;
             result:=LongWord(LongInt(result shl 5) - LongInt(result)) xor LongWord(P^);
             inc(p);
           end;
-{$ifdef overflowon}
-{$Q+}
-{$undef overflowon}
-{$endif}
+{$pop}
       end;
 
     function FPHash(P: PChar; Len: Integer): LongWord;
       Var
         pmax : pchar;
       begin
-{$ifopt Q+}
-{$define overflowon}
-{$Q-}
-{$endif}
+{$push}
+{$q-,r-}
         result:=0;
         pmax:=p+len;
         while (p<pmax) do
@@ -1122,10 +1115,7 @@ end;
             result:=LongWord(LongInt(result shl 5) - LongInt(result)) xor LongWord(P^);
             inc(p);
           end;
-{$ifdef overflowon}
-{$Q+}
-{$undef overflowon}
-{$endif}
+{$pop}
       end;
 
 

+ 4 - 4
compiler/cfileutl.pas

@@ -52,7 +52,7 @@ interface
         FDirectoryEntries : TFPHashList;
         FCached : Boolean;
         procedure FreeDirectoryEntries;
-        function GetItemAttr(const AName: TCmdStr): byte;
+        function GetItemAttr(const AName: TCmdStr): longint;
         function TryUseCache: boolean;
         procedure ForceUseCache;
         procedure Reload;
@@ -236,7 +236,7 @@ end;
       end;
 
 
-    function TCachedDirectory.GetItemAttr(const AName: TCmdStr): byte;
+    function TCachedDirectory.GetItemAttr(const AName: TCmdStr): longint;
       var
         entry: PCachedDirectoryEntry;
       begin
@@ -523,8 +523,8 @@ end;
         if (length(s)>0) and (s[1] in AllowDirectorySeparators) then
           result:=true;
 {$elseif defined(amiga) or defined(morphos)}
-        (* An Amiga path is absolute, if it has a volume/device name in it (contains ":"), 
-           otherwise it's always a relative path, no matter if it starts with a directory 
+        (* An Amiga path is absolute, if it has a volume/device name in it (contains ":"),
+           otherwise it's always a relative path, no matter if it starts with a directory
            separator or not. (KB) *)
         if (length(s)>0) and (Pos(':',s) <> 0) then
           result:=true;

+ 60 - 8
compiler/cmsgs.pas

@@ -53,14 +53,18 @@ type
     msgidx      : array[1..maxmsgidxparts] of PArrayOfPChar;
     msgidxmax   : array[1..maxmsgidxparts] of longint;
     msgstates   : array[1..maxmsgidxparts] of PArrayOfState;
+    { set if changes with $WARN need to be cleared at next module change }
+    has_local_changes : boolean;
     constructor Init(n:longint;const idxmax:array of longint);
     destructor  Done;
     function  LoadIntern(p:pointer;n:longint):boolean;
     function  LoadExtern(const fn:string):boolean;
     procedure ClearIdx;
+    procedure ResetStates;
     procedure CreateIdx;
     function  GetPChar(nr:longint):pchar;
-    function  ClearVerbosity(nr:longint):boolean;
+    { function  ClearVerbosity(nr:longint):boolean; not used anymore }
+    function  SetVerbosity(nr:longint;newstate:tmsgstate):boolean;
     function  Get(nr:longint;const args:array of TMsgStr):ansistring;
   end;
 
@@ -107,9 +111,10 @@ end;
 
 constructor TMessage.Init(n:longint;const idxmax:array of longint);
 var
-  i : longint;
+  i,j : longint;
 begin
   msgtxt:=nil;
+  has_local_changes:=false;
   msgsize:=0;
   msgparts:=n;
   if n<>high(idxmax)+1 then
@@ -122,7 +127,9 @@ begin
      fillchar(msgidx[i]^,msgidxmax[i]*sizeof(pointer),0);
      { create array of states }
      getmem(msgstates[i],msgidxmax[i]*sizeof(tmsgstate));
-     fillchar(msgstates[i]^,msgidxmax[i]*sizeof(tmsgstate),0);
+     { default value for msgstate is ms_on_global }
+     for j:=0 to msgidxmax[i]-1 do
+       msgstates[i]^[j]:=ms_on_global;
    end;
 end;
 
@@ -387,31 +394,76 @@ end;
 
 function TMessage.GetPChar(nr:longint):pchar;
 begin
-  GetPChar:=msgidx[nr div 1000]^[nr mod 1000];
+  if (nr div 1000 < msgparts) and
+     (nr mod 1000 <  msgidxmax[nr div 1000]) then
+    GetPChar:=msgidx[nr div 1000]^[nr mod 1000]
+  else
+    GetPChar:='';
 end;
 
-function TMessage.ClearVerbosity(nr:longint):boolean;
+function TMessage.SetVerbosity(nr:longint;newstate:tmsgstate):boolean;
 var
   i: longint;
+  oldstate : tmsgstate;
+  is_global : boolean;
 begin
   result:=false;
   i:=nr div 1000;
   if (i < low(msgstates)) or
      (i > msgparts) then
     exit;
-  msgstates[i]^[nr mod 1000]:=ms_off;
-  result:=true;
+  if (nr mod 1000 < msgidxmax[i]) then
+    begin
+      is_global:=(ord(newstate) and ms_global_mask) <> 0;
+      oldstate:=msgstates[i]^[nr mod 1000];
+      if not is_global then
+        newstate:= tmsgstate((ord(newstate) and ms_local_mask) or (ord(oldstate) and ms_global_mask));
+      if newstate<>oldstate then
+        has_local_changes:=true;
+      msgstates[i]^[nr mod 1000]:=newstate;
+      result:=true;
+    end;
 end;
 
+{
+function TMessage.ClearVerbosity(nr:longint):boolean;
+begin
+  ClearVerbosity:=SetVerbosity(nr,ms_off);
+end;
+}
+
 function TMessage.Get(nr:longint;const args:array of TMsgStr):ansistring;
 var
   hp : pchar;
 begin
-  hp:=msgidx[nr div 1000]^[nr mod 1000];
+  if (nr div 1000 < msgparts) and
+     (nr mod 1000 <  msgidxmax[nr div 1000]) then
+    hp:=msgidx[nr div 1000]^[nr mod 1000]
+  else
+    hp:=nil;
   if hp=nil then
     Get:='msg nr '+tostr(nr)
   else
     Get:=MsgReplace(system.strpas(hp),args);
 end;
 
+procedure TMessage.ResetStates;
+var
+  i,j,glob : longint;
+  state : tmsgstate;
+begin
+  if not has_local_changes then
+    exit;
+  for i:=1 to msgparts do
+    for j:=0 to msgidxmax[i] - 1 do
+      begin
+        state:=msgstates[i]^[j];
+        glob:=(ord(state) and ms_global_mask) shr ms_shift;
+        state:=tmsgstate((glob shl ms_shift) or glob);
+        msgstates[i]^[j]:=state;
+      end;
+  has_local_changes:=false;
+end;
+
+
 end.

+ 2 - 2
compiler/compinnr.inc

@@ -73,9 +73,9 @@ const
    in_readstr_x         = 63;
    in_abs_long          = 64;
    in_ror_x             = 65;
-   in_ror_x_x           = 66;
+   in_ror_x_y           = 66;
    in_rol_x             = 67;
-   in_rol_x_x           = 68;
+   in_rol_x_y           = 68;
    in_objc_selector_x   = 69;
    in_objc_protocol_x   = 70;
    in_objc_encode_x     = 71;

+ 4 - 0
compiler/constexp.pas

@@ -57,11 +57,15 @@ var   internalerror:errorproc;
 
 {Same issue, avoid dependency on cpuinfo because the cpu directory isn't
  searched during utils building.}
+{$ifdef GENERIC_CPU}
+type  bestreal=extended;
+{$else}
 {$ifdef x86}
 type  bestreal=extended;
 {$else}
 type  bestreal=double;
 {$endif}
+{$endif}
 
 operator := (const u:qword):Tconstexprint;inline;
 operator := (const s:int64):Tconstexprint;inline;

+ 41 - 4
compiler/dbgdwarf.pas

@@ -922,7 +922,7 @@ implementation
                       internalerror(200610011);
                     def.dwarf_lab:=current_asmdata.RefAsmSymbol(make_mangledname('DBG',def.owner,symname(def.typesym)));
                     def.dwarf_ref_lab:=current_asmdata.RefAsmSymbol(make_mangledname('DBGREF',def.owner,symname(def.typesym)));
-                    if is_class_or_interface_or_dispinterface(def) then
+                    if is_class_or_interface_or_dispinterface(def) or is_objectpascal_helper(def) then
                       tobjectdef(def).dwarf_struct_lab:=current_asmdata.RefAsmSymbol(make_mangledname('DBG2',def.owner,symname(def.typesym)));
                     def.dbg_state:=dbg_state_written;
                   end
@@ -936,7 +936,7 @@ implementation
                       begin
                         def.dwarf_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG',def.owner,symname(def.typesym)),AB_GLOBAL,AT_DATA);
                         def.dwarf_ref_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBGREF',def.owner,symname(def.typesym)),AB_GLOBAL,AT_DATA);
-                        if is_class_or_interface_or_dispinterface(def) then
+                        if is_class_or_interface_or_dispinterface(def) or is_objectpascal_helper(def) then
                           tobjectdef(def).dwarf_struct_lab:=current_asmdata.DefineAsmSymbol(make_mangledname('DBG2',def.owner,symname(def.typesym)),AB_GLOBAL,AT_DATA);
                         include(def.defstates,ds_dwarf_dbg_info_written);
                       end
@@ -1418,8 +1418,7 @@ implementation
                 ]);
               finish_entry;
             end;
-          pasbool,
-          bool8bit :
+          pasbool8 :
             begin
               append_entry(DW_TAG_base_type,false,[
                 DW_AT_name,DW_FORM_string,'Boolean'#0,
@@ -1428,6 +1427,24 @@ implementation
                 ]);
               finish_entry;
             end;
+          bool8bit :
+            begin
+              append_entry(DW_TAG_base_type,false,[
+                DW_AT_name,DW_FORM_string,'ByteBool'#0,
+                DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
+                DW_AT_byte_size,DW_FORM_data1,1
+                ]);
+              finish_entry;
+            end;
+          pasbool16 :
+            begin
+              append_entry(DW_TAG_base_type,false,[
+                DW_AT_name,DW_FORM_string,'Boolean16'#0,
+                DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
+                DW_AT_byte_size,DW_FORM_data1,2
+                ]);
+              finish_entry;
+            end;
           bool16bit :
             begin
               append_entry(DW_TAG_base_type,false,[
@@ -1437,6 +1454,15 @@ implementation
                 ]);
               finish_entry;
             end;
+          pasbool32 :
+            begin
+              append_entry(DW_TAG_base_type,false,[
+                DW_AT_name,DW_FORM_string,'Boolean32'#0,
+                DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
+                DW_AT_byte_size,DW_FORM_data1,4
+                ]);
+              finish_entry;
+            end;
           bool32bit :
             begin
               append_entry(DW_TAG_base_type,false,[
@@ -1446,6 +1472,15 @@ implementation
                 ]);
               finish_entry;
             end;
+          pasbool64 :
+            begin
+              append_entry(DW_TAG_base_type,false,[
+                DW_AT_name,DW_FORM_string,'Boolean64'#0,
+                DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
+                DW_AT_byte_size,DW_FORM_data1,8
+                ]);
+              finish_entry;
+            end;
           bool64bit :
             begin
               append_entry(DW_TAG_base_type,false,[
@@ -3506,6 +3541,7 @@ implementation
           odt_interfacecom,
           odt_interfacecorba,
           odt_dispinterface,
+          odt_helper,
           odt_class:
             begin
               { implicit pointer }
@@ -3913,6 +3949,7 @@ implementation
               dostruct(DW_TAG_interface_type);
               doparent(true);
             end;
+          odt_helper,
           odt_class:
             begin
               //dostruct(DW_TAG_class_type);

+ 8 - 2
compiler/dbgstabs.pas

@@ -624,7 +624,10 @@ implementation
             case def.ordtype of
               uvoid :
                 ss:=def_stab_number(def);
-              pasbool,
+              pasbool8,
+              pasbool16,
+              pasbool32,
+              pasbool64,
               bool8bit,
               bool16bit,
               bool32bit,
@@ -647,13 +650,16 @@ implementation
                 ss:='-20;';
               uwidechar :
                 ss:='-30;';
-              pasbool,
+              pasbool8,
               bool8bit :
                 ss:='-21;';
+              pasbool16,
               bool16bit :
                 ss:='-22;';
+              pasbool32,
               bool32bit :
                 ss:='-23;';
+              pasbool64,
               bool64bit :
                 { no clue if this is correct (FK) }
                 ss:='-23;';

+ 16 - 6
compiler/defcmp.pas

@@ -166,7 +166,8 @@ implementation
           (bvoid,
            bint,bint,bint,bint,
            bint,bint,bint,bint,
-           bbool,bbool,bbool,bbool,bbool,
+           bbool,bbool,bbool,bbool,
+           bbool,bbool,bbool,bbool,
            bchar,bchar,bint);
 
         basedefconvertsimplicit : array[tbasedef,tbasedef] of tconverttype =
@@ -241,7 +242,8 @@ implementation
                                 end;
                             end;
                           uvoid,
-                          pasbool,bool8bit,bool16bit,bool32bit,bool64bit:
+                          pasbool8,pasbool16,pasbool32,pasbool64,
+                          bool8bit,bool16bit,bool32bit,bool64bit:
                             eq:=te_equal;
                           else
                             internalerror(200210061);
@@ -536,7 +538,12 @@ implementation
                           (s64currencytype.typ = floatdef))) then
                        begin
                          doconv:=tc_int_2_real;
-                         eq:=te_convert_l4;
+
+                         { prefer single over others }
+                         if is_single(def_to) then
+                           eq:=te_convert_l3
+                         else
+                           eq:=te_convert_l4;
                        end
                      else if is_currency(def_from)
                              { and (s64currencytype.typ = orddef)) } then
@@ -659,7 +666,9 @@ implementation
                   equal_defs(def_from,tarraydef(def_to).elementdef) then
                 begin
                   doconv:=tc_equal;
-                  eq:=te_convert_l1;
+                  { also update in htypechk.pas/var_para_allowed if changed
+                    here }
+                  eq:=te_convert_l3;
                 end
                else
                 begin
@@ -1544,8 +1553,9 @@ implementation
                 u8bit,u16bit,u32bit,u64bit,
                 s8bit,s16bit,s32bit,s64bit :
                   is_subequal:=(torddef(def2).ordtype in [s64bit,u64bit,s32bit,u32bit,u8bit,s8bit,s16bit,u16bit]);
-                pasbool,bool8bit,bool16bit,bool32bit,bool64bit :
-                  is_subequal:=(torddef(def2).ordtype in [pasbool,bool8bit,bool16bit,bool32bit,bool64bit]);
+                pasbool8,pasbool16,pasbool32,pasbool64,
+                bool8bit,bool16bit,bool32bit,bool64bit :
+                  is_subequal:=(torddef(def2).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64,bool8bit,bool16bit,bool32bit,bool64bit]);
                 uchar :
                   is_subequal:=(torddef(def2).ordtype=uchar);
                 uwidechar :

+ 11 - 3
compiler/defutil.pas

@@ -265,6 +265,9 @@ interface
         or not }
     function is_nested_pd(def: tabstractprocdef): boolean;{$ifdef USEINLINE}inline;{$endif}
 
+    { # returns whether def is a type parameter of a generic }
+    function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
+
 implementation
 
     uses
@@ -384,7 +387,8 @@ implementation
                is_ordinal:=dt in [uchar,uwidechar,
                                   u8bit,u16bit,u32bit,u64bit,
                                   s8bit,s16bit,s32bit,s64bit,
-                                  pasbool,bool8bit,bool16bit,bool32bit,bool64bit];
+                                  pasbool8,pasbool16,pasbool32,pasbool64,
+                                  bool8bit,bool16bit,bool32bit,bool64bit];
              end;
            enumdef :
              is_ordinal:=true;
@@ -441,14 +445,14 @@ implementation
     function is_boolean(def : tdef) : boolean;
       begin
         result:=(def.typ=orddef) and
-                    (torddef(def).ordtype in [pasbool,bool8bit,bool16bit,bool32bit,bool64bit]);
+                    (torddef(def).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64,bool8bit,bool16bit,bool32bit,bool64bit]);
       end;
 
 
     function is_pasbool(def : tdef) : boolean;
       begin
         result:=(def.typ=orddef) and
-                    (torddef(def).ordtype = pasbool);
+                    (torddef(def).ordtype in [pasbool8,pasbool16,pasbool32,pasbool64]);
       end;
 
     { true if def is a C-style boolean (non-zero value = true, zero = false) }
@@ -1142,4 +1146,8 @@ implementation
       end;
 
 
+    function is_typeparam(def : tdef) : boolean;{$ifdef USEINLINE}inline;{$endif}
+      begin
+        result:=(def.typ=undefineddef);
+      end;
 end.

+ 25 - 6
compiler/fmodule.pas

@@ -199,7 +199,7 @@ interface
         function  resolve_unit(id:longint):tmodule;
         procedure allunitsused;
         procedure setmodulename(const s:string);
-        procedure AddExternalImport(const libname,symname:string;OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
+        procedure AddExternalImport(const libname,symname,symmangledname:string;OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
         property ImportLibraryList : TFPHashObjectList read FImportLibraryList;
       end;
 
@@ -955,21 +955,40 @@ implementation
       end;
 
 
-    procedure TModule.AddExternalImport(const libname,symname:string;OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
+    procedure TModule.AddExternalImport(const libname,symname,symmangledname:string;
+              OrdNr: longint;isvar:boolean;ImportByOrdinalOnly:boolean);
       var
-        ImportLibrary : TImportLibrary;
-        ImportSymbol  : TFPHashObject;
+        ImportLibrary,OtherIL : TImportLibrary;
+        ImportSymbol  : TImportSymbol;
+        i : longint;
       begin
         ImportLibrary:=TImportLibrary(ImportLibraryList.Find(libname));
         if not assigned(ImportLibrary) then
           ImportLibrary:=TImportLibrary.Create(ImportLibraryList,libname);
-        ImportSymbol:=TFPHashObject(ImportLibrary.ImportSymbolList.Find(symname));
+        ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList.Find(symname));
         if not assigned(ImportSymbol) then
           begin
+            { Check that the same name does not exist in another library }
+            { If it does and the same mangled name is used, issue a warning }
+            if ImportLibraryList.Count>1 then
+              for i:=0 To ImportLibraryList.Count-1 do
+                begin
+                  OtherIL:=TImportLibrary(ImportLibraryList.Items[i]);
+                  ImportSymbol:=TImportSymbol(OtherIL.ImportSymbolList.Find(symname));
+                  if assigned(ImportSymbol) then
+                    begin
+                      if ImportSymbol.MangledName=symmangledname then
+                        begin
+                          CGMessage3(sym_w_library_overload,symname,libname,OtherIL.Name);
+                          break;
+                        end;
+                    end;
+                end;
             if not ImportByOrdinalOnly then
               { negative ordinal number indicates import by name with ordinal number as hint }
               OrdNr:=-OrdNr;
-            ImportSymbol:=TImportSymbol.Create(ImportLibrary.ImportSymbolList,symname,OrdNr,isvar);
+            ImportSymbol:=TImportSymbol.Create(ImportLibrary.ImportSymbolList,
+              symname,symmangledname,OrdNr,isvar);
           end;
       end;
 

+ 17 - 0
compiler/fpcdefs.inc

@@ -28,6 +28,23 @@
 
 {$define USEEXCEPT}
 
+{ If anyone wants to use interrupt for
+  a specific target, add a
+  $define FPC_HAS_SYSTEMS_INTERRUPT_TABLE
+  to fpcdefs.inc to reactivate
+  the corresponding code }
+{$undef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
+
+{ This fake CPU is used to allow incorporation of globtype unit
+  into utils/ppudump without any CPU specific code PM }
+{$ifdef generic_cpu}
+  {$define cpu32bit}
+  {$define cpu32bitaddr}
+  {$define cpu32bitalu}
+  {$define cpuflags}
+  {$define cpuextended}
+{$endif generic_cpu}
+
 {$ifdef cpuarm}
   {$packrecords c}
 {$endif cpuarm}

+ 5 - 1
compiler/fppu.pas

@@ -634,6 +634,7 @@ var
               begin
                 ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
                 ppufile.putstring(ImportSymbol.Name);
+                ppufile.putstring(ImportSymbol.MangledName);
                 ppufile.putlongint(ImportSymbol.OrdNr);
                 ppufile.putbyte(byte(ImportSymbol.IsVar));
               end;
@@ -894,6 +895,7 @@ var
         extsymcnt   : longint;
         ImportLibrary  : TImportLibrary;
         extsymname  : string;
+        extsymmangledname : string;
         extsymordnr : longint;
         extsymisvar : boolean;
       begin
@@ -904,9 +906,11 @@ var
             for j:=0 to extsymcnt-1 do
               begin
                 extsymname:=ppufile.getstring;
+                extsymmangledname:=ppufile.getstring;
                 extsymordnr:=ppufile.getlongint;
                 extsymisvar:=(ppufile.getbyte<>0);
-                TImportSymbol.Create(ImportLibrary.ImportSymbolList,extsymname,extsymordnr,extsymisvar);
+                TImportSymbol.Create(ImportLibrary.ImportSymbolList,extsymname,
+                  extsymmangledname,extsymordnr,extsymisvar);
               end;
           end;
       end;

+ 51 - 0
compiler/generic/cpuinfo.pas

@@ -0,0 +1,51 @@
+{
+    Copyright (c) 1998-2002 by the Free Pascal development team
+
+    Basic Processor information for the Generic CPU
+    This file is used by PPUDump program from utils subdirectory.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+Unit CPUInfo;
+
+Interface
+
+  uses
+    globtype;
+
+Type
+   bestreal = extended;
+   ts32real = single;
+   ts64real = double;
+   ts80real = type extended;
+   ts128real = type extended;
+   ts64comp = comp;
+
+   pbestreal=^bestreal;
+
+   { possible supported processors for this target }
+   tcputype =
+      (cpu_none
+      );
+
+
+Type
+   tfputype =
+     (fpu_none,
+      fpu_soft
+     );
+
+Const
+   cputypestr : array[tcputype] of string[8] = ('none');
+   fputypestr : array[tfputype] of string[6] = ('none','soft');
+
+Implementation
+
+end.

+ 36 - 21
compiler/globals.pas

@@ -121,6 +121,7 @@ interface
          debugswitches   : tdebugswitches;
          { 0: old behaviour for sets <=256 elements
            >0: round to this size }
+         pmessage : pmessagestaterecord;
          setalloc,
          packenum        : shortint;
 
@@ -176,11 +177,13 @@ interface
         property items[I:longint]:TLinkRec read getlinkrec; default;
       end;
 
+
       tpendingstate = record
         nextverbositystr : shortstring;
         nextlocalswitches : tlocalswitches;
         nextverbosityfullswitch: longint;
         nextcallingstr : shortstring;
+        nextmessagerecord : pmessagestaterecord;
         verbosityfullswitched,
         localswitcheschanged : boolean;
       end;
@@ -236,6 +239,8 @@ interface
        autoloadunits      : string;
 
        { linking }
+       usegnubinutils : boolean;
+       forceforwardslash : boolean;
        usewindowapi  : boolean;
        description   : string;
        SetPEFlagsSetExplicity,
@@ -356,6 +361,7 @@ interface
         genwpoptimizerswitches : [];
         dowpoptimizerswitches : [];
         debugswitches : [];
+        pmessage : nil;
 
         setalloc : 0;
         packenum : 4;
@@ -363,51 +369,60 @@ interface
         packrecords     : 0;
         maxfpuregisters : 0;
 
-{$ifdef i386}
+{ Note: GENERIC_CPU is sued together with generic subdirectory to
+  be able to compile some of the units without any real CPU.
+  This is used to generate a CPU independant PPUDUMP utility. PM }
+{$ifdef GENERIC_CPU}
+        cputype : cpu_none;
+        optimizecputype : cpu_none;
+        fputype : fpu_none;
+{$else not GENERIC_CPU}
+  {$ifdef i386}
         cputype : cpu_Pentium;
         optimizecputype : cpu_Pentium3;
         fputype : fpu_x87;
-{$endif i386}
-{$ifdef m68k}
+  {$endif i386}
+  {$ifdef m68k}
         cputype : cpu_MC68020;
         optimizecputype : cpu_MC68020;
         fputype : fpu_soft;
-{$endif m68k}
-{$ifdef powerpc}
+  {$endif m68k}
+  {$ifdef powerpc}
         cputype : cpu_PPC604;
         optimizecputype : cpu_ppc7400;
         fputype : fpu_standard;
-{$endif powerpc}
-{$ifdef POWERPC64}
+  {$endif powerpc}
+  {$ifdef POWERPC64}
         cputype : cpu_PPC970;
         optimizecputype : cpu_ppc970;
         fputype : fpu_standard;
-{$endif POWERPC64}
-{$ifdef sparc}
+  {$endif POWERPC64}
+  {$ifdef sparc}
         cputype : cpu_SPARC_V8;
         optimizecputype : cpu_SPARC_V8;
         fputype : fpu_hard;
-{$endif sparc}
-{$ifdef arm}
+  {$endif sparc}
+  {$ifdef arm}
         cputype : cpu_armv3;
         optimizecputype : cpu_armv3;
         fputype : fpu_fpa;
-{$endif arm}
-{$ifdef x86_64}
+  {$endif arm}
+  {$ifdef x86_64}
         cputype : cpu_athlon64;
         optimizecputype : cpu_athlon64;
         fputype : fpu_sse64;
-{$endif x86_64}
-{$ifdef avr}
+  {$endif x86_64}
+  {$ifdef avr}
         cputype : cpuinfo.cpu_avr5;
         optimizecputype : cpuinfo.cpu_avr5;
         fputype : fpu_none;
-{$endif avr}
-{$ifdef mips}
+  {$endif avr}
+  {$ifdef mips}
         cputype : cpu_mips32;
         optimizecputype : cpu_mips32;
         fputype : fpu_mips2;
-{$endif mips}
+  {$endif mips}
+{$endif not GENERIC_CPU}
         asmmode : asmmode_standard;
         interfacetype : it_interfacecom;
         defproccall : pocall_default;
@@ -415,9 +430,9 @@ interface
         minfpconstprec : s32real;
 
         disabledircache : false;
-{$if defined(ARM)}
+{$if defined(ARM) or defined(AVR)}
         controllertype : ct_none;
-{$endif defined(ARM)}
+{$endif defined(ARM) or defined(AVR)}
       );
 
     var
@@ -1160,7 +1175,7 @@ implementation
           else { Error }
            UpdateAlignmentStr:=false;
         until false;
-        UpdateAlignment(a,b);
+        Result:=Result and UpdateAlignment(a,b);
       end;
 
 

+ 25 - 3
compiler/globtype.pas

@@ -517,10 +517,32 @@ interface
     type
       { a message state }
       tmsgstate = (
-        ms_on,    // turn on output
-        ms_off,   // turn off output
-        ms_error  // cast to error
+        ms_on := 1,
+        ms_off := 2,
+        ms_error := 3,
+
+        ms_on_global := $11,    // turn on output
+        ms_off_global := $22,   // turn off output
+        ms_error_global := $33  // cast to error
       );
+    const
+      { Mask for current value of message state }
+      ms_local_mask = $0f;
+      { Mask for global value of message state
+        that needs to be restored when changing units }
+      ms_global_mask = $f0;
+      { Shift used to convert global to local message state }
+      ms_shift = 4;
+
+    type
+      pmessagestaterecord = ^tmessagestaterecord;
+      tmessagestaterecord = record
+        next : pmessagestaterecord;
+        value : longint;
+        state : tmsgstate;
+      end;
+
+
 
 implementation
 

+ 19 - 2
compiler/htypechk.pas

@@ -1609,7 +1609,7 @@ implementation
                     eq:=te_convert_l2
                   else
                     if equal_defs(def_from,tarraydef(def_to).elementdef) then
-                      eq:=te_convert_l2;
+                      eq:=te_convert_l3;
                 end;
             end;
           pointerdef :
@@ -1865,6 +1865,22 @@ implementation
                if not hasoverload then
                  break;
              end;
+           if is_objectpascal_helper(structdef) then
+             begin
+               if not assigned(tobjectdef(structdef).extendeddef) then
+                 Internalerror(2011062601);
+               { search methods in the extended type as well }
+               srsym:=tprocsym(tobjectdef(structdef).extendeddef.symtable.FindWithHash(hashedid));
+               if assigned(srsym) and
+                  { Delphi allows hiding a property by a procedure with the same name }
+                  (srsym.typ=procsym) then
+                 begin
+                   hasoverload:=processprocsym(tprocsym(srsym));
+                   { when there is no explicit overload we stop searching }
+                   if not hasoverload then
+                     break;
+                 end;
+             end;
            { next parent }
            if (structdef.typ=objectdef) then
              structdef:=tobjectdef(structdef).childof
@@ -2477,7 +2493,8 @@ implementation
         variantorddef_cl: array[tordtype] of tvariantequaltype =
           (tve_incompatible,tve_byte,tve_word,tve_cardinal,tve_chari64,
            tve_shortint,tve_smallint,tve_longint,tve_chari64,
-           tve_boolformal,tve_boolformal,tve_boolformal,tve_boolformal,tve_boolformal,
+           tve_boolformal,tve_boolformal,tve_boolformal,tve_boolformal,
+           tve_boolformal,tve_boolformal,tve_boolformal,tve_boolformal,
            tve_chari64,tve_chari64,tve_dblcurrency);
 { TODO: fixme for 128 bit floats }
         variantfloatdef_cl: array[tfloattype] of tvariantequaltype =

+ 30 - 1
compiler/i386/cgcpu.pas

@@ -217,6 +217,7 @@ unit cgcpu;
       var
         tmpreg : tregister;
         opsize : topsize;
+        tmpref : treference;
       begin
         with r do
           begin
@@ -229,7 +230,35 @@ unit cgcpu;
                 if (segment=NR_NO) and (base=NR_NO) and (index=NR_NO) then
                   begin
                     if assigned(symbol) then
-                      list.concat(Taicpu.Op_sym_ofs(A_PUSH,opsize,symbol,offset))
+                      begin
+                        if (target_info.system in [system_i386_darwin,system_i386_iphonesim]) and
+                           ((r.symbol.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL]) or
+                            (cs_create_pic in current_settings.moduleswitches)) then
+                          begin
+                            tmpreg:=getaddressregister(list);
+                            a_loadaddr_ref_reg(list,r,tmpreg);
+                            list.concat(taicpu.op_reg(A_PUSH,opsize,tmpreg));
+                          end
+                        else if cs_create_pic in current_settings.moduleswitches then
+                          begin
+                            if offset<>0 then
+                              begin
+                                tmpreg:=getaddressregister(list);
+                                a_loadaddr_ref_reg(list,r,tmpreg);
+                                list.concat(taicpu.op_reg(A_PUSH,opsize,tmpreg));
+                              end
+                            else
+                              begin
+                                reference_reset_symbol(tmpref,r.symbol,0,r.alignment);
+                                tmpref.refaddr:=addr_pic;
+                                tmpref.base:=current_procinfo.got;
+                                include(current_procinfo.flags,pi_needs_got);
+                                list.concat(taicpu.op_ref(A_PUSH,S_L,tmpref));
+                              end
+                          end
+                        else
+                          list.concat(Taicpu.Op_sym_ofs(A_PUSH,opsize,symbol,offset));
+                      end
                     else
                       list.concat(Taicpu.Op_const(A_PUSH,opsize,offset));
                   end

+ 1 - 1
compiler/i386/cputarg.pas

@@ -92,7 +92,7 @@ implementation
       ,agx86att
     {$endif}
     {$ifndef NOAG386NSM}
-      ,ag386nsm
+      ,agx86nsm
     {$endif}
     {$ifndef NOAG386INT}
       ,agx86int

+ 1 - 1
compiler/i386/i386nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-1202;
+1203;

+ 23 - 16
compiler/i386/i386tab.inc

@@ -2369,7 +2369,7 @@
   (
     opcode  : A_IN;
     ops     : 2;
-    optypes : (ot_reg_ax or ot_bits32 or ot_bits64,ot_immediate,ot_none);
+    optypes : (ot_reg_ax or ot_bits32,ot_immediate,ot_none);
     code    : #208#1#229#21;
     flags   : if_8086 or if_sb
   ),
@@ -2383,7 +2383,7 @@
   (
     opcode  : A_IN;
     ops     : 2;
-    optypes : (ot_reg_ax or ot_bits32 or ot_bits64,ot_reg_dx,ot_none);
+    optypes : (ot_reg_ax or ot_bits32,ot_reg_dx,ot_none);
     code    : #208#1#237;
     flags   : if_8086
   ),
@@ -2530,7 +2530,7 @@
   (
     opcode  : A_JMP;
     ops     : 1;
-    optypes : (ot_immediate or ot_bits16 or ot_bits32 or ot_bits64,ot_none,ot_none);
+    optypes : (ot_immediate or ot_bits16 or ot_bits32,ot_none,ot_none);
     code    : #208#1#233#52;
     flags   : if_8086 or if_pass2
   ),
@@ -2915,9 +2915,16 @@
   (
     opcode  : A_MOV;
     ops     : 2;
-    optypes : (ot_mem_offs,ot_reg_ax or ot_bits32,ot_none);
-    code    : #208#1#163#28;
-    flags   : if_8086 or if_sm or if_nox86_64
+    optypes : (ot_mem_offs,ot_reg_ax,ot_none);
+    code    : #212#1#163#36;
+    flags   : if_8086 or if_sm
+  ),
+  (
+    opcode  : A_MOV;
+    ops     : 2;
+    optypes : (ot_mem_offs,ot_reg_eax,ot_none);
+    code    : #213#1#163#36;
+    flags   : if_386 or if_sm
   ),
   (
     opcode  : A_MOV;
@@ -2930,15 +2937,15 @@
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg_ax,ot_mem_offs,ot_none);
-    code    : #212#1#161#29;
-    flags   : if_8086 or if_sm or if_nox86_64
+    code    : #212#1#161#37;
+    flags   : if_8086 or if_sm
   ),
   (
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg_eax,ot_mem_offs,ot_none);
-    code    : #213#1#161#29;
-    flags   : if_386 or if_sm or if_nox86_64
+    code    : #213#1#161#37;
+    flags   : if_386 or if_sm
   ),
   (
     opcode  : A_MOV;
@@ -2950,8 +2957,8 @@
   (
     opcode  : A_MOV;
     ops     : 2;
-    optypes : (ot_reg32 or ot_bits64,ot_immediate,ot_none);
-    code    : #208#8#184#29;
+    optypes : (ot_reg32,ot_immediate,ot_none);
+    code    : #213#8#184#33;
     flags   : if_386 or if_sd
   ),
   (
@@ -2979,8 +2986,8 @@
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_mem_offs,ot_reg_al,ot_none);
-    code    : #1#162#28;
-    flags   : if_8086 or if_sm or if_nox86_64
+    code    : #1#162#36;
+    flags   : if_8086 or if_sm
   ),
   (
     opcode  : A_MOV;
@@ -2993,8 +3000,8 @@
     opcode  : A_MOV;
     ops     : 2;
     optypes : (ot_reg_al,ot_mem_offs,ot_none);
-    code    : #1#160#29;
-    flags   : if_8086 or if_sm or if_nox86_64
+    code    : #1#160#37;
+    flags   : if_8086 or if_sm
   ),
   (
     opcode  : A_MOV;

+ 6 - 4
compiler/i386/popt386.pas

@@ -719,12 +719,14 @@ begin
                          (taicpu(hp1).opcode = A_AND) and
                          (taicpu(hp1).oper[0]^.typ = top_const) and
                          (taicpu(hp1).oper[1]^.typ = top_reg) and
-                         (taicpu(p).oper[1]^.reg = taicpu(hp1).oper[1]^.reg) then
+                         (getsupreg(taicpu(p).oper[1]^.reg)=getsupreg(taicpu(hp1).oper[1]^.reg)) and
+                         (getsubreg(taicpu(p).oper[1]^.reg)<=getsubreg(taicpu(hp1).oper[1]^.reg)) then
     {change "and const1, reg; and const2, reg" to "and (const1 and const2), reg"}
                         begin
-                          taicpu(p).loadConst(0,taicpu(p).oper[0]^.val and taicpu(hp1).oper[0]^.val);
-                          asml.remove(hp1);
-                          hp1.free;
+                          taicpu(hp1).loadConst(0,taicpu(p).oper[0]^.val and taicpu(hp1).oper[0]^.val);
+                          asml.remove(p);
+                          p.free;
+                          p:=hp1;
                         end
                       else
     {change "and x, reg; jxx" to "test x, reg", if reg is deallocated before the

+ 183 - 18
compiler/link.pas

@@ -63,7 +63,7 @@ interface
          Procedure AddStaticCLibrary(const S : TCmdStr);
          Procedure AddSharedCLibrary(S : TCmdStr);
          Procedure AddFramework(S : TCmdStr);
-         procedure AddImportSymbol(const libname,symname:TCmdStr;OrdNr: longint;isvar:boolean);virtual;
+         procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);virtual;
          Procedure InitSysInitUnitName;virtual;
          Function  MakeExecutable:boolean;virtual;
          Function  MakeSharedLibrary:boolean;virtual;
@@ -84,6 +84,9 @@ interface
          Function  MakeStaticLibrary:boolean;override;
        end;
 
+      TBooleanArray = array [1..1024] of boolean;
+      PBooleanArray = ^TBooleanArray;
+
       TInternalLinker = class(TLinker)
       private
          FCExeOutput : TExeOutputClass;
@@ -93,7 +96,10 @@ interface
          FImportLibraryList : TFPHashObjectList;
          procedure Load_ReadObject(const para:TCmdStr);
          procedure Load_ReadStaticLibrary(const para:TCmdStr);
+         procedure ParseScript_Handle;
+         procedure ParseScript_PostCheck;
          procedure ParseScript_Load;
+         function  ParsePara(const para : string) : string;
          procedure ParseScript_Order;
          procedure ParseScript_MemPos;
          procedure ParseScript_DataPos;
@@ -101,6 +107,8 @@ interface
          function  RunLinkScript(const outputname:TCmdStr):boolean;
       protected
          linkscript : TCmdStrList;
+         ScriptCount : longint;
+         IsHandled : PBooleanArray;
          property CObjInput:TObjInputClass read FCObjInput write FCObjInput;
          property CExeOutput:TExeOutputClass read FCExeOutput write FCExeOutput;
          property StaticLibraryList:TFPHashObjectList read FStaticLibraryList;
@@ -108,11 +116,12 @@ interface
          procedure DefaultLinkScript;virtual;abstract;
       public
          IsSharedLibrary : boolean;
+         UseStabs : boolean;
          Constructor Create;override;
          Destructor Destroy;override;
          Function  MakeExecutable:boolean;override;
          Function  MakeSharedLibrary:boolean;override;
-         procedure AddImportSymbol(const libname,symname:TCmdStr;OrdNr: longint;isvar:boolean);override;
+         procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);override;
        end;
 
     var
@@ -249,7 +258,9 @@ Implementation
         Found:=FindFile(s,'.'+source_info.DirSep,false,founddll);
         if (not found) then
          Found:=librarysearchpath.FindFile(s,false,founddll);
-        if (not found) then
+
+        { when cross compiling, it is pretty useless to search windir etc. for dlls }
+        if (not found) and (source_info.system=target_info.system) then
          begin
            sysdir:=FixPath(GetEnvironmentVariable('windir'),false);
            Found:=FindFile(s,sysdir+';'+sysdir+'system'+source_info.DirSep+';'+sysdir+'system32'+source_info.DirSep,false,founddll);
@@ -369,6 +380,7 @@ Implementation
                    mask:=mask or link_static;
                end;
               { smart linking ? }
+
               if (cs_link_smart in current_settings.globalswitches) then
                begin
                  if (flags and uf_smart_linked)=0 then
@@ -431,14 +443,15 @@ Implementation
                for j:=0 to ImportLibrary.ImportSymbolList.Count-1 do
                  begin
                    ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
-                   AddImportSymbol(ImportLibrary.Name,ImportSymbol.Name,ImportSymbol.OrdNr,ImportSymbol.IsVar);
+                   AddImportSymbol(ImportLibrary.Name,ImportSymbol.Name,
+                     ImportSymbol.MangledName,ImportSymbol.OrdNr,ImportSymbol.IsVar);
                  end;
              end;
          end;
       end;
 
 
-    procedure TLinker.AddImportSymbol(const libname,symname:TCmdStr;OrdNr: longint;isvar:boolean);
+    procedure TLinker.AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);
       begin
       end;
 
@@ -516,7 +529,7 @@ Implementation
       end;
 
 
-    procedure AddImportSymbol(const libname,symname:TCmdStr;OrdNr: longint;isvar:boolean);
+    procedure AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);
       begin
       end;
 
@@ -806,7 +819,10 @@ Implementation
         FImportLibraryList:=TFPHashObjectList.Create(true);
         exemap:=nil;
         exeoutput:=nil;
+        UseStabs:=false;
         CObjInput:=TObjInput;
+        ScriptCount:=0;
+        IsHandled:=nil;
       end;
 
 
@@ -815,6 +831,12 @@ Implementation
         linkscript.free;
         StaticLibraryList.Free;
         ImportLibraryList.Free;
+        if assigned(IsHandled) then
+          begin
+            FreeMem(IsHandled,sizeof(boolean)*ScriptCount);
+            IsHandled:=nil;
+            ScriptCount:=0;
+          end;
         if assigned(exeoutput) then
           begin
             exeoutput.free;
@@ -829,7 +851,7 @@ Implementation
       end;
 
 
-    procedure TInternalLinker.AddImportSymbol(const libname,symname:TCmdStr;OrdNr: longint;isvar:boolean);
+    procedure TInternalLinker.AddImportSymbol(const libname,symname,symmangledname:TCmdStr;OrdNr: longint;isvar:boolean);
       var
         ImportLibrary : TImportLibrary;
         ImportSymbol  : TFPHashObject;
@@ -839,7 +861,7 @@ Implementation
           ImportLibrary:=TImportLibrary.Create(ImportLibraryList,libname);
         ImportSymbol:=TFPHashObject(ImportLibrary.ImportSymbolList.Find(symname));
         if not assigned(ImportSymbol) then
-          ImportSymbol:=TImportSymbol.Create(ImportLibrary.ImportSymbolList,symname,OrdNr,isvar);
+          ImportSymbol:=TImportSymbol.Create(ImportLibrary.ImportSymbolList,symname,symmangledname,OrdNr,isvar);
       end;
 
 
@@ -880,24 +902,116 @@ Implementation
       end;
 
 
+    procedure TInternalLinker.ParseScript_Handle;
+      var
+        s, para, keyword : String;
+        hp : TCmdStrListItem;
+        i : longint;
+      begin
+        hp:=TCmdStrListItem(linkscript.first);
+        i:=0;
+        while assigned(hp) do
+          begin
+            inc(i);
+            s:=hp.str;
+            if (s='') or (s[1]='#') then
+              continue;
+            keyword:=Upper(GetToken(s,' '));
+            para:=GetToken(s,' ');
+            if Trim(s)<>'' then
+              Comment(V_Warning,'Unknown part "'+s+'" in "'+hp.str+'" internal linker script');
+            if (keyword<>'SYMBOL') and
+               (keyword<>'SYMBOLS') and
+               (keyword<>'STABS') and
+               (keyword<>'PROVIDE') and
+               (keyword<>'ZEROS') and
+               (keyword<>'BYTE') and
+               (keyword<>'WORD') and
+               (keyword<>'LONG') and
+               (keyword<>'QUAD') and
+               (keyword<>'ENTRYNAME') and
+               (keyword<>'ISSHAREDLIBRARY') and
+               (keyword<>'IMAGEBASE') and
+               (keyword<>'READOBJECT') and
+               (keyword<>'READSTATICLIBRARY') and
+               (keyword<>'EXESECTION') and
+               (keyword<>'ENDEXESECTION') and
+               (keyword<>'OBJSECTION') and
+               (keyword<>'HEADER')
+               then
+              Comment(V_Warning,'Unknown keyword "'+keyword+'" in "'+hp.str
+                +'" internal linker script');
+            hp:=TCmdStrListItem(hp.next);
+          end;
+        ScriptCount:=i;
+        if ScriptCount>0 then
+          begin
+            GetMem(IsHandled,sizeof(boolean)*ScriptCount);
+            Fillchar(IsHandled^,sizeof(boolean)*ScriptCount,#0);
+          end;
+      end;
+
+    procedure TInternalLinker.ParseScript_PostCheck;
+      var
+        s : String;
+        hp : TCmdStrListItem;
+        i : longint;
+      begin
+        hp:=TCmdStrListItem(linkscript.first);
+        i:=0;
+        while assigned(hp) do
+          begin
+            inc(i);
+            if not IsHandled^[i] then
+              begin
+                s:=hp.str;
+                Comment(V_Warning,'"'+hp.str+
+                  '" internal linker script not handled');
+              end;
+            hp:=TCmdStrListItem(hp.next);
+          end;
+      end;
+
+    function  TInternalLinker.ParsePara(const para : string) : string;
+      var
+        res : string;
+      begin
+        res:=trim(para);
+        { Remove enclosing braces }
+        if (length(res)>0) and (res[1]='(') and
+           (res[length(res)]=')') then
+          res:=trim(copy(res,2,length(res)-2));
+        result:=res;
+      end;
+
     procedure TInternalLinker.ParseScript_Load;
       var
         s,
         para,
         keyword : String;
         hp : TCmdStrListItem;
+        i : longint;
+        handled : boolean;
       begin
         exeoutput.Load_Start;
         hp:=TCmdStrListItem(linkscript.first);
+        i:=0;
         while assigned(hp) do
           begin
+            inc(i);
             s:=hp.str;
             if (s='') or (s[1]='#') then
-              continue;
+              begin
+                IsHandled^[i]:=true;
+                continue;
+              end;
+            handled:=true;
             keyword:=Upper(GetToken(s,' '));
-            para:=GetToken(s,' ');
+            para:=ParsePara(GetToken(s,' '));
             if keyword='SYMBOL' then
               ExeOutput.Load_Symbol(para)
+            else if keyword='PROVIDE' then
+              ExeOutput.Load_ProvideSymbol(para)
             else if keyword='ENTRYNAME' then
               ExeOutput.Load_EntryName(para)
             else if keyword='ISSHAREDLIBRARY' then
@@ -906,8 +1020,14 @@ Implementation
               ExeOutput.Load_ImageBase(para)
             else if keyword='READOBJECT' then
               Load_ReadObject(para)
+            else if keyword='STABS' then
+              UseStabs:=true
             else if keyword='READSTATICLIBRARY' then
-              Load_ReadStaticLibrary(para);
+              Load_ReadStaticLibrary(para)
+            else
+              handled:=false;
+            if handled then
+              IsHandled^[i]:=true;
             hp:=TCmdStrListItem(hp.next);
           end;
       end;
@@ -919,16 +1039,22 @@ Implementation
         para,
         keyword : String;
         hp : TCmdStrListItem;
+        i : longint;
+        handled : boolean;
       begin
         exeoutput.Order_Start;
         hp:=TCmdStrListItem(linkscript.first);
+        i:=0;
         while assigned(hp) do
           begin
+            inc(i);
             s:=hp.str;
             if (s='') or (s[1]='#') then
               continue;
+            handled:=true;
             keyword:=Upper(GetToken(s,' '));
-            para:=GetToken(s,' ');
+            para:=ParsePara(GetToken(s,' '));
+
             if keyword='EXESECTION' then
               ExeOutput.Order_ExeSection(para)
             else if keyword='ENDEXESECTION' then
@@ -937,8 +1063,22 @@ Implementation
               ExeOutput.Order_ObjSection(para)
             else if keyword='ZEROS' then
               ExeOutput.Order_Zeros(para)
+            else if keyword='BYTE' then
+              ExeOutput.Order_Values(1,para)
+            else if keyword='WORD' then
+              ExeOutput.Order_Values(2,para)
+            else if keyword='LONG' then
+              ExeOutput.Order_Values(4,para)
+            else if keyword='QUAD' then
+              ExeOutput.Order_Values(8,para)
             else if keyword='SYMBOL' then
-              ExeOutput.Order_Symbol(para);
+              ExeOutput.Order_Symbol(para)
+            else if keyword='PROVIDE' then
+              ExeOutput.Order_ProvideSymbol(para)
+            else
+              handled:=false;
+            if handled then
+              IsHandled^[i]:=true;
             hp:=TCmdStrListItem(hp.next);
           end;
         exeoutput.Order_End;
@@ -951,22 +1091,31 @@ Implementation
         para,
         keyword : String;
         hp : TCmdStrListItem;
+        i : longint;
+        handled : boolean;
       begin
         exeoutput.MemPos_Start;
         hp:=TCmdStrListItem(linkscript.first);
+        i:=0;
         while assigned(hp) do
           begin
+            inc(i);
             s:=hp.str;
             if (s='') or (s[1]='#') then
               continue;
+            handled:=true;
             keyword:=Upper(GetToken(s,' '));
-            para:=GetToken(s,' ');
+            para:=ParsePara(GetToken(s,' '));
             if keyword='EXESECTION' then
               ExeOutput.MemPos_ExeSection(para)
             else if keyword='ENDEXESECTION' then
               ExeOutput.MemPos_EndExeSection
             else if keyword='HEADER' then
-              ExeOutput.MemPos_Header;
+              ExeOutput.MemPos_Header
+            else
+              handled:=false;
+            if handled then
+              IsHandled^[i]:=true;
             hp:=TCmdStrListItem(hp.next);
           end;
       end;
@@ -978,16 +1127,21 @@ Implementation
         para,
         keyword : String;
         hp : TCmdStrListItem;
+        i : longint;
+        handled : boolean;
       begin
         exeoutput.DataPos_Start;
         hp:=TCmdStrListItem(linkscript.first);
+        i:=0;
         while assigned(hp) do
           begin
+            inc(i);
             s:=hp.str;
             if (s='') or (s[1]='#') then
               continue;
+            handled:=true;
             keyword:=Upper(GetToken(s,' '));
-            para:=GetToken(s,' ');
+            para:=ParsePara(GetToken(s,' '));
             if keyword='EXESECTION' then
               ExeOutput.DataPos_ExeSection(para)
             else if keyword='ENDEXESECTION' then
@@ -995,7 +1149,11 @@ Implementation
             else if keyword='HEADER' then
               ExeOutput.DataPos_Header
             else if keyword='SYMBOLS' then
-              ExeOutput.DataPos_Symbols;
+              ExeOutput.DataPos_Symbols
+            else
+              handled:=false;
+            if handled then
+              IsHandled^[i]:=true;
             hp:=TCmdStrListItem(hp.next);
           end;
       end;
@@ -1041,6 +1199,8 @@ Implementation
 
         PrintLinkerScript;
 
+        { Check that syntax is OK }
+        ParseScript_Handle;
         { Load .o files and resolve symbols }
         ParseScript_Load;
         exeoutput.ResolveSymbols(StaticLibraryList);
@@ -1057,7 +1217,9 @@ Implementation
         { Create .exe sections and add .o sections }
         ParseScript_Order;
         exeoutput.RemoveUnreferencedSections;
-        exeoutput.MergeStabs;
+        { if UseStabs then, this would remove
+          STABS for empty linker scripts }
+          exeoutput.MergeStabs;
         exeoutput.RemoveEmptySections;
         if ErrorCount>0 then
           goto myexit;
@@ -1091,6 +1253,9 @@ Implementation
             exeoutput.WriteExeFile(outputname);
           end;
 
+        { Post check that everything was handled }
+        ParseScript_PostCheck;
+
 { TODO: fixed section names}
         status.codesize:=exeoutput.findexesection('.text').size;
         status.datasize:=exeoutput.findexesection('.data').size;

+ 4 - 4
compiler/m68k/n68kadd.pas

@@ -358,12 +358,12 @@ implementation
         otl,ofl : tasmlabel;
       begin
 //        writeln('second_cmpboolean');
-        if (torddef(left.resultdef).ordtype in [pasbool,bool8bit]) or
-           (torddef(right.resultdef).ordtype in [pasbool,bool8bit]) then
+        if (torddef(left.resultdef).ordtype in [pasbool8,bool8bit]) or
+           (torddef(right.resultdef).ordtype in [pasbool8,bool8bit]) then
          cgsize:=OS_8
         else
-          if (torddef(left.resultdef).ordtype=bool16bit) or
-             (torddef(right.resultdef).ordtype=bool16bit) then
+          if (torddef(left.resultdef).ordtype in [pasbool16,bool16bit]) or
+             (torddef(right.resultdef).ordtype in [pasbool16,bool16bit]) then
            cgsize:=OS_16
         else
            cgsize:=OS_32;

+ 2 - 2
compiler/mips/aasmcpu.pas

@@ -28,7 +28,7 @@ interface
 uses
   cclasses,
   globtype, globals, verbose,
-  aasmbase, aasmtai,
+  aasmbase, aasmsym, aasmtai,
   cgbase, cgutils, cpubase, cpuinfo;
 
 const
@@ -38,7 +38,7 @@ const
   O_MOV_DEST   = 1;
 
 type
-  taicpu = class(tai_cpu_abstract)
+  taicpu = class(tai_cpu_abstract_sym)
     delayslot_annulled: boolean;   { conditinal opcode with ,a }
     constructor op_none(op: tasmop);
 

+ 1 - 1
compiler/mips/cgcpu.pas

@@ -1667,7 +1667,7 @@ begin
     Internalerror(200109191);
 
   make_global := False;
-  if (not current_module.is_unit) or
+  if (not current_module.is_unit) or create_smartlink or
     (procdef.owner.defowner.owner.symtabletype = globalsymtable) then
     make_global := True;
 

+ 2 - 2
compiler/mips/cpuinfo.pas

@@ -58,11 +58,11 @@ Const
      pocall_cppdecl
    ];
 
-   cputypestr : array[tcputype] of string[5] = ('',
+   cputypestr : array[tcputype] of string[6] = ('',
      'MIPS32'
    );
 
-   fputypestr : array[tfputype] of string[6] = ('',
+   fputypestr : array[tfputype] of string[9] = ('',
      'SOFT',
      'FPU_MIPS2','FPU_MIPS3'
    );

+ 1 - 1
compiler/mips/ncpucnv.pas

@@ -156,7 +156,7 @@ begin
       s64real:
       begin
         hregister := cg.getfpuregister(current_asmdata.CurrAsmList, OS_F64);
-        current_asmdata.asmlists[al_typedconsts].concat(tai_align.Create(const_align(8)));
+        new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,l1.name,const_align(8));
         current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
 
         { I got this constant from a test program (FK) }

+ 41 - 14
compiler/msg/errore.msg

@@ -364,6 +364,9 @@ scan_w_multiple_main_name_overrides=02086_W_Overriding name of "main" procedure
 % name will be used.
 scanner_w_illegal_warn_identifier=02087_W_Illegal identifier "$1" for $WARN directive
 % Identifier is not known by a \var{\{\$WARN\}} compiler directive.
+scanner_e_illegal_alignment_directive=02088_E_Illegal alignment directive
+% The alignment directive is not valid. Either the alignment type is not known or the alignment
+% value is not a power of two.
 % \end{description}
 #
 # Parser
@@ -1669,7 +1672,7 @@ type_w_pointer_to_signed=04082_W_Converting pointers to signed integers may resu
 % For example both \windows and \linux allow pointers in the range \$0000000 to \$bfffffff.
 % If you convert pointers to signed types, this can cause overflow and range check errors,
 % but also \$80000000 < \$7fffffff. This can cause random errors in code like "if p>q".
-type_interface_has_no_guid=04083_E_Interface type $1 has no valid GUID
+type_e_interface_has_no_guid=04083_E_Interface type $1 has no valid GUID
 % When applying the as-operator to an interface or class, the desired interface (i.e. the right operand of the
 % as-operator) must have a valid GUID.
 type_e_invalid_objc_selector_name=04084_E_Invalid selector name "$1"
@@ -1751,7 +1754,7 @@ type_e_record_helper_must_extend_same_record=04102_E_Derived record helper must
 #
 # Symtable
 #
-# 05080 is the last used one
+# 05084 is the last used one
 #
 % \section{Symbol handling}
 % This section lists all the messages that concern the handling of symbols.
@@ -1990,11 +1993,17 @@ sym_e_objc_formal_class_not_resolved=05080_E_No complete definition of the forma
 % of the class to be in scope.
 sym_e_interprocgoto_into_init_final_code_not_allowed=05081_E_Gotos into initialization or finalization blocks of units are not allowed
 % Gotos into initialization or finalization blockse of units are not allowed.
-sym_e_external_class_name_mismatch1=05082=E_Invalid external name "$1" for formal class "$2"
-sym_e_external_class_name_mismatch2=05083=E_Complete class definition with external name "$1" here
+sym_e_external_class_name_mismatch1=05082_E_Invalid external name "$1" for formal class "$2"
+sym_e_external_class_name_mismatch2=05083_E_Complete class definition with external name "$1" here
 % When a class is declared using a formal external definition, the actual external
 % definition (if any) must specify the same external name as the formal definition
 % (since both definitions refer to the same actual class type).
+sym_w_library_overload=05084_W_Possible library conflict: symbol "$1" from library "$2" also found in library "$3"
+% Some OS do not have library specific namespaces, for those
+% OS, the function declared as "external 'libname' name 'funcname'",
+% the 'libname' part is only a hint, funcname might also be loaded
+% by another library. This warning appears if 'funcname' is used twice
+% with two different library names.
 %
 % \end{description}
 #
@@ -2296,7 +2305,7 @@ asmr_w_id_supposed_external=07072_W_Identifier $1 supposed external
 % problems at link time if the symbol is not defined anywhere.
 asmr_e_string_not_allowed_as_const=07073_E_Strings not allowed as constants
 % Character strings are not allowed as constants.
-asmr_e_no_var_type_specified=07074_No type of variable specified
+asmr_e_no_var_type_specified=07074_E_No type of variable specified
 % The syntax expects a type idenfitifer after the dot, but
 % none was found.
 asmr_w_assembler_code_not_returned_to_text=07075_E_assembler code not returned to text section
@@ -3090,6 +3099,11 @@ option_help_pages=11025_[
 3*2Acoff_COFF (Go32v2) using internal writer
 3*2Apecoff_PE-COFF (Win32) using internal writer
 4*2Aas_Assemble using GNU AS
+4*2Agas_Assemble using GNU GAS
+4*2Agas-darwin_Assemble darwin Mach-O64 using GNU GAS
+4*2Amasm_Win64 object file using ml64 (Microsoft)
+4*2Apecoff_PE-COFF (Win64) using internal writer
+4*2Aelf_ELF (Linux-64bit) using internal writer
 6*2Aas_Unix o-file using GNU AS
 6*2Agas_GNU Motorola assembler
 6*2Amit_MIT Syntax (old GAS)
@@ -3285,19 +3299,27 @@ S*2Tlinux_Linux
 **2*_    with full path              v : Write fpcdebug.txt with
 **2*_                                    lots of debugging info
 **2*_m<x>,<y> : Don't show messages numbered <x> and <y>
-3*1W<x>_Target-specific options (targets)
-A*1W<x>_Target-specific options (targets)
-P*1W<x>_Target-specific options (targets)
-p*1W<x>_Target-specific options (targets)
+**1W<x>_Target-specific options (targets)
+3*2WA_Specify native type application (Windows)
+4*2WA_Specify native type application (Windows)
+A*2WA_Specify native type application (Windows)
 3*2Wb_Create a bundle instead of a library (Darwin)
 P*2Wb_Create a bundle instead of a library (Darwin)
 p*2Wb_Create a bundle instead of a library (Darwin)
-3*2WB_Create a relocatable image (Windows)
+A*2Wb_Create a bundle instead of a library (Darwin)
+4*2Wb_Create a bundle instead of a library (Darwin)
+3*2WB_Create a relocatable image (Windows, Symbian)
+3*2WBxxxx_Set image base to xxxx (Windows, Symbian)
+4*2WB_Create a relocatable image (Windows)
+4*2WBxxxx_Set image base to xxxx (Windows)
 A*2WB_Create a relocatable image (Windows, Symbian)
+A*2WBxxxx_Set image base to xxxx (Windows, Symbian)
 3*2WC_Specify console type application (EMX, OS/2, Windows)
+4*2WC_Specify console type application (EMX, OS/2, Windows)
 A*2WC_Specify console type application (Windows)
 P*2WC_Specify console type application (Classic Mac OS)
 3*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)
+4*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)
 A*2WD_Use DEFFILE to export functions of DLL or EXE (Windows)
 3*2We_Use external resources (Darwin)
 4*2We_Use external resources (Darwin)
@@ -3306,20 +3328,25 @@ P*2We_Use external resources (Darwin)
 p*2We_Use external resources (Darwin)
 3*2WF_Specify full-screen type application (EMX, OS/2)
 3*2WG_Specify graphic type application (EMX, OS/2, Windows)
+4*2WG_Specify graphic type application (EMX, OS/2, Windows)
 A*2WG_Specify graphic type application (Windows)
 P*2WG_Specify graphic type application (Classic Mac OS)
 3*2Wi_Use internal resources (Darwin)
+4*2Wi_Use internal resources (Darwin)
+A*2Wi_Use internal resources (Darwin)
 P*2Wi_Use internal resources (Darwin)
 p*2Wi_Use internal resources (Darwin)
+3*2WI_Turn on/off the usage of import sections (Windows)
+4*2WI_Turn on/off the usage of import sections (Windows)
+A*2WI_Turn on/off the usage of import sections (Windows)
 3*2WN_Do not generate relocation code, needed for debugging (Windows)
+4*2WN_Do not generate relocation code, needed for debugging (Windows)
 A*2WN_Do not generate relocation code, needed for debugging (Windows)
 3*2WR_Generate relocation code (Windows)
+4*2WR_Generate relocation code (Windows)
 A*2WR_Generate relocation code (Windows)
 P*2WT_Specify MPW tool type application (Classic Mac OS)
-3*2WX_Enable executable stack (Linux)
-A*2WX_Enable executable stack (Linux)
-p*2WX_Enable executable stack (Linux)
-P*2WX_Enable executable stack (Linux)
+**2WX_Enable executable stack (Linux)
 **1X_Executable options:
 **2Xc_Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
 **2Xd_Do not use standard library search path (needed for cross compile)

+ 5 - 3
compiler/msgidx.inc

@@ -107,6 +107,7 @@ const
   scan_e_illegal_minfpconstprec=02085;
   scan_w_multiple_main_name_overrides=02086;
   scanner_w_illegal_warn_identifier=02087;
+  scanner_e_illegal_alignment_directive=02088;
   parser_e_syntax_error=03000;
   parser_e_dont_nest_interrupt=03004;
   parser_w_proc_directive_ignored=03005;
@@ -472,7 +473,7 @@ const
   type_h_convert_sub_operands_to_prevent_overflow=04080;
   type_h_convert_mul_operands_to_prevent_overflow=04081;
   type_w_pointer_to_signed=04082;
-  type_interface_has_no_guid=04083;
+  type_e_interface_has_no_guid=04083;
   type_e_invalid_objc_selector_name=04084;
   type_e_expected_objc_method_but_got=04085;
   type_e_expected_objc_method=04086;
@@ -562,6 +563,7 @@ const
   sym_e_interprocgoto_into_init_final_code_not_allowed=05081;
   sym_e_external_class_name_mismatch1=05082;
   sym_e_external_class_name_mismatch2=05083;
+  sym_w_library_overload=05084;
   cg_e_parasize_too_big=06009;
   cg_e_file_must_call_by_reference=06012;
   cg_e_cant_use_far_pointer_there=06013;
@@ -893,9 +895,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 59465;
+  MsgTxtSize = 60574;
 
   MsgIdxMax : array[1..20] of longint=(
-    24,88,311,103,84,54,111,23,202,63,
+    24,89,311,103,85,54,111,23,202,63,
     49,20,1,1,1,1,1,1,1,1
   );

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 393 - 388
compiler/msgtxt.inc


+ 70 - 61
compiler/nadd.pas

@@ -334,17 +334,17 @@ implementation
                  else
                    t:=cordconstnode.create(lv and rv,resultdef,true);
                ltn :
-                 t:=cordconstnode.create(ord(lv<rv),booltype,true);
+                 t:=cordconstnode.create(ord(lv<rv),pasbool8type,true);
                lten :
-                 t:=cordconstnode.create(ord(lv<=rv),booltype,true);
+                 t:=cordconstnode.create(ord(lv<=rv),pasbool8type,true);
                gtn :
-                 t:=cordconstnode.create(ord(lv>rv),booltype,true);
+                 t:=cordconstnode.create(ord(lv>rv),pasbool8type,true);
                gten :
-                 t:=cordconstnode.create(ord(lv>=rv),booltype,true);
+                 t:=cordconstnode.create(ord(lv>=rv),pasbool8type,true);
                equaln :
-                 t:=cordconstnode.create(ord(lv=rv),booltype,true);
+                 t:=cordconstnode.create(ord(lv=rv),pasbool8type,true);
                unequaln :
-                 t:=cordconstnode.create(ord(lv<>rv),booltype,true);
+                 t:=cordconstnode.create(ord(lv<>rv),pasbool8type,true);
                slashn :
                  begin
                    { int/int becomes a real }
@@ -387,30 +387,30 @@ implementation
                 case nodetype of
                  ltn:
                    if lv<low then
-                     t:=Cordconstnode.create(1,booltype,true)
+                     t:=Cordconstnode.create(1,pasbool8type,true)
                    else if lv>=high then
-                     t:=Cordconstnode.create(0,booltype,true);
+                     t:=Cordconstnode.create(0,pasbool8type,true);
                  lten:
                    if lv<=low then
-                     t:=Cordconstnode.create(1,booltype,true)
+                     t:=Cordconstnode.create(1,pasbool8type,true)
                    else if lv>high then
-                     t:=Cordconstnode.create(0,booltype,true);
+                     t:=Cordconstnode.create(0,pasbool8type,true);
                  gtn:
                    if lv<=low then
-                     t:=Cordconstnode.create(0,booltype,true)
+                     t:=Cordconstnode.create(0,pasbool8type,true)
                    else if lv>high then
-                     t:=Cordconstnode.create(1,booltype,true);
+                     t:=Cordconstnode.create(1,pasbool8type,true);
                  gten :
                    if lv<low then
-                     t:=Cordconstnode.create(0,booltype,true)
+                     t:=Cordconstnode.create(0,pasbool8type,true)
                    else if lv>=high then
-                     t:=Cordconstnode.create(1,booltype,true);
+                     t:=Cordconstnode.create(1,pasbool8type,true);
                  equaln:
                    if (lv<low) or (lv>high) then
-                     t:=Cordconstnode.create(0,booltype,true);
+                     t:=Cordconstnode.create(0,pasbool8type,true);
                  unequaln:
                    if (lv<low) or (lv>high) then
-                     t:=Cordconstnode.create(1,booltype,true);
+                     t:=Cordconstnode.create(1,pasbool8type,true);
                 end;
               if t<>nil then
                 begin
@@ -436,30 +436,30 @@ implementation
                 case nodetype of
                  ltn:
                    if high<rv then
-                     t:=Cordconstnode.create(1,booltype,true)
+                     t:=Cordconstnode.create(1,pasbool8type,true)
                    else if low>=rv then
-                     t:=Cordconstnode.create(0,booltype,true);
+                     t:=Cordconstnode.create(0,pasbool8type,true);
                  lten:
                    if high<=rv then
-                     t:=Cordconstnode.create(1,booltype,true)
+                     t:=Cordconstnode.create(1,pasbool8type,true)
                    else if low>rv then
-                     t:=Cordconstnode.create(0,booltype,true);
+                     t:=Cordconstnode.create(0,pasbool8type,true);
                  gtn:
                    if high<=rv then
-                     t:=Cordconstnode.create(0,booltype,true)
+                     t:=Cordconstnode.create(0,pasbool8type,true)
                    else if low>rv then
-                     t:=Cordconstnode.create(1,booltype,true);
+                     t:=Cordconstnode.create(1,pasbool8type,true);
                  gten:
                    if high<rv then
-                     t:=Cordconstnode.create(0,booltype,true)
+                     t:=Cordconstnode.create(0,pasbool8type,true)
                    else if low>=rv then
-                     t:=Cordconstnode.create(1,booltype,true);
+                     t:=Cordconstnode.create(1,pasbool8type,true);
                  equaln:
                    if (rv<low) or (rv>high) then
-                     t:=Cordconstnode.create(0,booltype,true);
+                     t:=Cordconstnode.create(0,pasbool8type,true);
                  unequaln:
                    if (rv<low) or (rv>high) then
-                     t:=Cordconstnode.create(1,booltype,true);
+                     t:=Cordconstnode.create(1,pasbool8type,true);
                 end;
               if t<>nil then
                 begin
@@ -563,17 +563,17 @@ implementation
                 slashn :
                   t:=crealconstnode.create(lvd/rvd,resultrealdef);
                 ltn :
-                  t:=cordconstnode.create(ord(lvd<rvd),booltype,true);
+                  t:=cordconstnode.create(ord(lvd<rvd),pasbool8type,true);
                 lten :
-                  t:=cordconstnode.create(ord(lvd<=rvd),booltype,true);
+                  t:=cordconstnode.create(ord(lvd<=rvd),pasbool8type,true);
                 gtn :
-                  t:=cordconstnode.create(ord(lvd>rvd),booltype,true);
+                  t:=cordconstnode.create(ord(lvd>rvd),pasbool8type,true);
                 gten :
-                  t:=cordconstnode.create(ord(lvd>=rvd),booltype,true);
+                  t:=cordconstnode.create(ord(lvd>=rvd),pasbool8type,true);
                 equaln :
-                  t:=cordconstnode.create(ord(lvd=rvd),booltype,true);
+                  t:=cordconstnode.create(ord(lvd=rvd),pasbool8type,true);
                 unequaln :
-                  t:=cordconstnode.create(ord(lvd<>rvd),booltype,true);
+                  t:=cordconstnode.create(ord(lvd<>rvd),pasbool8type,true);
                 else
                   internalerror(2008022102);
              end;
@@ -602,17 +602,17 @@ implementation
                      t:=cstringconstnode.createwstr(ws1);
                   end;
                 ltn :
-                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<0),booltype,true);
+                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<0),pasbool8type,true);
                 lten :
-                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<=0),booltype,true);
+                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<=0),pasbool8type,true);
                 gtn :
-                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>0),booltype,true);
+                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>0),pasbool8type,true);
                 gten :
-                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>=0),booltype,true);
+                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>=0),pasbool8type,true);
                 equaln :
-                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)=0),booltype,true);
+                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)=0),pasbool8type,true);
                 unequaln :
-                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<>0),booltype,true);
+                  t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<>0),pasbool8type,true);
                 else
                   internalerror(2008022103);
              end;
@@ -676,17 +676,17 @@ implementation
                     tstringconstnode(t).changestringtype(resultdef);
                   end;
                 ltn :
-                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<0),booltype,true);
+                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<0),pasbool8type,true);
                 lten :
-                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<=0),booltype,true);
+                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<=0),pasbool8type,true);
                 gtn :
-                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>0),booltype,true);
+                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>0),pasbool8type,true);
                 gten :
-                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>=0),booltype,true);
+                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>=0),pasbool8type,true);
                 equaln :
-                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)=0),booltype,true);
+                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)=0),pasbool8type,true);
                 unequaln :
-                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),booltype,true);
+                  t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),pasbool8type,true);
                 else
                   internalerror(2008022104);
              end;
@@ -724,22 +724,22 @@ implementation
                unequaln :
                   begin
                     b:=tsetconstnode(right).value_set^ <> tsetconstnode(left).value_set^;
-                    t:=cordconstnode.create(byte(b),booltype,true);
+                    t:=cordconstnode.create(byte(b),pasbool8type,true);
                   end;
                equaln :
                   begin
                     b:=tsetconstnode(right).value_set^ = tsetconstnode(left).value_set^;
-                    t:=cordconstnode.create(byte(b),booltype,true);
+                    t:=cordconstnode.create(byte(b),pasbool8type,true);
                   end;
                lten :
                   begin
                     b:=tsetconstnode(left).value_set^ <= tsetconstnode(right).value_set^;
-                    t:=cordconstnode.create(byte(b),booltype,true);
+                    t:=cordconstnode.create(byte(b),pasbool8type,true);
                   end;
                gten :
                   begin
                     b:=tsetconstnode(left).value_set^ >= tsetconstnode(right).value_set^;
-                    t:=cordconstnode.create(byte(b),booltype,true);
+                    t:=cordconstnode.create(byte(b),pasbool8type,true);
                   end;
                 else
                   internalerror(2008022105);
@@ -826,6 +826,13 @@ implementation
 
       begin
          result:=nil;
+         { avoid any problems with type parameters later on }
+         if is_typeparam(left.resultdef) or is_typeparam(right.resultdef) then
+           begin
+             resultdef:=cundefinedtype;
+             exit;
+           end;
+
          { both left and right need to be valid }
          set_varstate(left,vs_read,[vsf_must_be_valid]);
          set_varstate(right,vs_read,[vsf_must_be_valid]);
@@ -891,17 +898,19 @@ implementation
           operation on a float and int are also handled }
 {$ifdef x86}
         { use extended as default real type only when the x87 fpu is used }
-{$ifdef i386}
+  {$ifdef i386}
         if not(current_settings.fputype=fpu_x87) then
-{$endif i386}
-{$ifdef x86_64}
-        { x86-64 has no x87 only mode, so use always double as default }
-        if true then
-{$endif x86_6}
           resultrealdef:=s64floattype
         else
-{$endif x86}
           resultrealdef:=pbestrealtype^;
+  {$endif i386}
+  {$ifdef x86_64}
+        { x86-64 has no x87 only mode, so use always double as default }
+        resultrealdef:=s64floattype;
+  {$endif x86_6}
+{$else not x86}
+        resultrealdef:=pbestrealtype^;
+{$endif not x86}
 
         if (right.resultdef.typ=floatdef) or (left.resultdef.typ=floatdef) then
          begin
@@ -1020,12 +1029,12 @@ implementation
                 begin
                   if not is_boolean(ld) then
                     begin
-                      inserttypeconv(left,booltype);
+                      inserttypeconv(left,pasbool8type);
                       ld := left.resultdef;
                     end;
                   if not is_boolean(rd) then
                     begin
-                      inserttypeconv(right,booltype);
+                      inserttypeconv(right,pasbool8type);
                       rd := right.resultdef;
                     end;
                 end;
@@ -1850,7 +1859,7 @@ implementation
           begin
              case nodetype of
                 ltn,lten,gtn,gten,equaln,unequaln :
-                  resultdef:=booltype;
+                  resultdef:=pasbool8type;
                 slashn :
                   resultdef:=resultrealdef;
                 addn:
@@ -2320,7 +2329,7 @@ implementation
 
         { otherwise, create the parameters for the helper }
         right := ccallparanode.create(
-          cordconstnode.create(ord(cs_check_overflow in current_settings.localswitches),booltype,true),
+          cordconstnode.create(ord(cs_check_overflow in current_settings.localswitches),pasbool8type,true),
           ccallparanode.create(right,ccallparanode.create(left,nil)));
         left := nil;
         { only qword needs the unsigned code, the
@@ -2450,7 +2459,7 @@ implementation
         if not(target_info.system in systems_wince) then
           begin
             if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
-              resultdef:=booltype;
+              resultdef:=pasbool8type;
             result:=ctypeconvnode.create_internal(ccallnode.createintern(procname,ccallparanode.create(
                 ctypeconvnode.create_internal(right,fdef),
                 ccallparanode.create(
@@ -2611,7 +2620,7 @@ implementation
                          internalerror(2011022301);
                      end;
                      result := ccallnode.createintern(procname,
-                       ccallparanode.create(cordconstnode.create(0,booltype,false),
+                       ccallparanode.create(cordconstnode.create(0,pasbool8type,false),
                        ccallparanode.create(right,
                        ccallparanode.create(left,nil))));
                      left := nil;

+ 2 - 2
compiler/nbas.pas

@@ -98,10 +98,10 @@ interface
                         ti_addr_taken,ti_executeinitialisation);
        ttempinfoflags = set of ttempinfoflag;
 
-const
+     const
        tempinfostoreflags = [ti_may_be_in_reg,ti_addr_taken];
 
-type
+     type
        { to allow access to the location by temp references even after the temp has }
        { already been disposed and to make sure the coherency between temps and     }
        { temp references is kept after a getcopy                                    }

+ 23 - 4
compiler/ncal.pas

@@ -1638,6 +1638,7 @@ implementation
     function tcallnode.gen_self_tree:tnode;
       var
         selftree : tnode;
+        selfdef  : tabstractrecorddef;
       begin
         selftree:=nil;
 
@@ -1685,7 +1686,13 @@ implementation
             begin
               if (procdefinition.typ<>procdef) then
                 internalerror(200305062);
-              if (oo_has_vmt in tprocdef(procdefinition).struct.objectoptions) then
+              { if the method belongs to a helper then we need to use the
+                extended type for references to Self }
+              if is_objectpascal_helper(tprocdef(procdefinition).struct) then
+                selfdef:=tobjectdef(tprocdef(procdefinition).struct).extendeddef
+              else
+                selfdef:=tprocdef(procdefinition).struct;
+              if (oo_has_vmt in selfdef.objectoptions) then
                 begin
                   { we only need the vmt, loading self is not required and there is no
                     need to check for typen, because that will always get the
@@ -2340,12 +2347,12 @@ implementation
                 else
                  if vo_is_range_check in para.parasym.varoptions then
                    begin
-                     para.left:=cordconstnode.create(Ord(cs_check_range in current_settings.localswitches),booltype,false);
+                     para.left:=cordconstnode.create(Ord(cs_check_range in current_settings.localswitches),pasbool8type,false);
                    end
                 else
                  if vo_is_overflow_check in para.parasym.varoptions then
                    begin
-                     para.left:=cordconstnode.create(Ord(cs_check_overflow in current_settings.localswitches),booltype,false);
+                     para.left:=cordconstnode.create(Ord(cs_check_overflow in current_settings.localswitches),pasbool8type,false);
                    end
                 else
                   if vo_is_msgsel in para.parasym.varoptions then
@@ -2868,7 +2875,19 @@ implementation
            begin
              if assigned(left) then
               begin
-                { ptr and settextbuf needs two args }
+                { convert types to those of the prototype, this is required by functions like ror, rol, sar
+                  some use however a dummy type (Typedfile) so this would break them }
+                if not(tprocdef(procdefinition).extnumber in [fpc_in_Reset_TypedFile,fpc_in_Rewrite_TypedFile]) then
+                  begin
+                    { bind parasyms to the callparanodes and insert hidden parameters }
+                    bind_parasym;
+
+                    { insert type conversions for parameters }
+                    if assigned(left) then
+                      tcallparanode(left).insert_typeconv;
+                  end;
+
+                { ptr and settextbuf need two args }
                 if assigned(tcallparanode(left).right) then
                  begin
                    hpt:=geninlinenode(tprocdef(procdefinition).extnumber,is_const,left);

+ 23 - 8
compiler/ncgadd.pas

@@ -463,15 +463,30 @@ interface
               else
                  internalerror(200203247);
             end;
-
-            if right.location.loc <> LOC_CONSTANT then
-              cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,cgop,location.size,
-                 left.location.register,right.location.register,
-                 location.register)
+{$ifndef cpu64bitalu}
+            if right.location.size in [OS_64,OS_S64] then
+              begin
+                if right.location.loc <> LOC_CONSTANT then
+                  cg64.a_op64_reg_reg_reg(current_asmdata.CurrAsmList,cgop,location.size,
+                     left.location.register64,right.location.register64,
+                     location.register64)
+                else
+                  cg64.a_op64_const_reg_reg(current_asmdata.CurrAsmList,cgop,location.size,
+                     right.location.value,left.location.register64,
+                     location.register64);
+              end
             else
-              cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,cgop,location.size,
-                 right.location.value,left.location.register,
-                 location.register);
+{$endif cpu64bitalu}
+              begin
+                if right.location.loc <> LOC_CONSTANT then
+                  cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,cgop,location.size,
+                     left.location.register,right.location.register,
+                     location.register)
+                else
+                  cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,cgop,location.size,
+                     right.location.value,left.location.register,
+                     location.register);
+              end;
          end;
       end;
 

+ 35 - 91
compiler/ncgcon.pas

@@ -109,10 +109,22 @@ implementation
       const
         floattype2ait:array[tfloattype] of taitype=
           (ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_real_80bit,ait_comp_64bit,ait_comp_64bit,ait_real_128bit);
+
+      { Since the value is stored always as bestreal, we share a single pool
+        between all float types. This requires type and hiloswapped flag to
+        be matched along with the value }
+      type
+        tfloatkey = record
+          value: bestreal;
+          typ: tfloattype;
+          swapped: boolean;
+        end;
+
       var
-         hp1 : tai;
          lastlabel : tasmlabel;
          realait : taitype;
+         entry : PHashSetItem;
+         key: tfloatkey;
 {$ifdef ARM}
          hiloswapped : boolean;
 {$endif ARM}
@@ -127,44 +139,25 @@ implementation
         { const already used ? }
         if not assigned(lab_real) then
           begin
-             { tries to find an old entry }
-             hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
-             while assigned(hp1) do
-               begin
-                  if hp1.typ=ait_label then
-                    lastlabel:=tai_label(hp1).labsym
-                  else
-                    begin
-                       if (hp1.typ=realait) and (lastlabel<>nil) then
-                         begin
-                            if is_number_float(value_real) and
-                              (
-                               ((realait=ait_real_32bit) and (tai_real_32bit(hp1).value=value_real) and is_number_float(tai_real_32bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_32bit(hp1).value))) or
-                               ((realait=ait_real_64bit) and
+            if current_asmdata.ConstPools[sp_floats] = nil then
+              current_asmdata.ConstPools[sp_floats] := THashSet.Create(64, True, False);
+
+            { there may be gap between record fields, zero it out }
+            fillchar(key,sizeof(key),0);
+            key.value:=value_real;
+            key.typ:=tfloatdef(resultdef).floattype;
 {$ifdef ARM}
-                                 ((tai_real_64bit(hp1).formatoptions=fo_hiloswapped)=hiloswapped) and
+            key.swapped:=hiloswapped;
 {$endif ARM}
-                                 (tai_real_64bit(hp1).value=value_real) and is_number_float(tai_real_64bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_64bit(hp1).value))) or
-                               ((realait=ait_real_80bit) and (tai_real_80bit(hp1).value=value_real) and (tai_real_80bit(hp1).savesize=resultdef.size) and is_number_float(tai_real_80bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_80bit(hp1).value))) or
-{$ifdef cpufloat128}
-                               ((realait=ait_real_128bit) and (tai_real_128bit(hp1).value=value_real) and is_number_float(tai_real_128bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_128bit(hp1).value))) or
-{$endif cpufloat128}
-                               ((realait=ait_comp_64bit) and (tai_comp_64bit(hp1).value=value_real) and is_number_float(tai_comp_64bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_comp_64bit(hp1).value)))
-                              ) then
-                              begin
-                                { found! }
-                                lab_real:=lastlabel;
-                                break;
-                              end;
-                         end;
-                       lastlabel:=nil;
-                    end;
-                  hp1:=tai(hp1.next);
-               end;
+            entry := current_asmdata.ConstPools[sp_floats].FindOrAdd(@key, sizeof(key));
+
+            lab_real := TAsmLabel(entry^.Data);  // is it needed anymore?
+
              { :-(, we must generate a new entry }
              if not assigned(lab_real) then
                begin
                   current_asmdata.getdatalabel(lastlabel);
+                  entry^.Data:=lastlabel;
                   lab_real:=lastlabel;
                   maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
                   new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(resultdef.alignment));
@@ -412,76 +405,27 @@ implementation
 
         procedure varsetconst;
         var
-           hp1         : tai;
            lastlabel   : tasmlabel;
            i           : longint;
-           neededtyp   : taiconst_type;
+           entry       : PHashSetItem;
         begin
           location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(8));
-          neededtyp:=aitconst_8bit;
           lastlabel:=nil;
           { const already used ? }
           if not assigned(lab_set) then
             begin
-              { tries to found an old entry }
-              hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
-              while assigned(hp1) do
-                begin
-                   if hp1.typ=ait_label then
-                     lastlabel:=tai_label(hp1).labsym
-                   else
-                     begin
-                       if (lastlabel<>nil) and
-                         (hp1.typ=ait_const) and
-                         (tai_const(hp1).consttype=neededtyp) then
-                         begin
-                           if (tai_const(hp1).consttype=aitconst_8bit) then
-                            begin
-                              { compare normal set }
-                              i:=0;
-                              while assigned(hp1) and (i<32) do
-                               begin
-                                 if (source_info.endian=target_info.endian) then
-                                   begin
-                                     if tai_const(hp1).value<>Psetbytes(value_set)^[i ] then
-                                       break
-                                   end
-                                 else if tai_const(hp1).value<>reverse_byte(Psetbytes(value_set)^[i]) then
-                                   break;
-                                 inc(i);
-                                 hp1:=tai(hp1.next);
-                               end;
-                              if i=32 then
-                               begin
-                                 { found! }
-                                 lab_set:=lastlabel;
-                                 break;
-                               end;
-                              { leave when the end of consts is reached, so no
-                                hp1.next is done }
-                              if not assigned(hp1) then
-                               break;
-                            end
-                           else
-                            begin
-                              { compare small set }
-                              if paint(value_set)^=tai_const(hp1).value then
-                               begin
-                                 { found! }
-                                 lab_set:=lastlabel;
-                                 break;
-                               end;
-                            end;
-                         end;
-                       lastlabel:=nil;
-                     end;
-                   hp1:=tai(hp1.next);
-                 end;
+              if current_asmdata.ConstPools[sp_varsets] = nil then
+                current_asmdata.ConstPools[sp_varsets] := THashSet.Create(64, True, False);
+              entry := current_asmdata.ConstPools[sp_varsets].FindOrAdd(value_set, 32);
+
+              lab_set := TAsmLabel(entry^.Data);  // is it needed anymore?
+
                { :-(, we must generate a new entry }
-               if not assigned(lab_set) then
+               if not assigned(entry^.Data) then
                  begin
                    current_asmdata.getdatalabel(lastlabel);
                    lab_set:=lastlabel;
+                   entry^.Data:=lastlabel;
                    maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
                    new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(8));
                    current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));

+ 4 - 4
compiler/ncginl.pas

@@ -163,9 +163,9 @@ implementation
               end;
 {$endif SUPPORT_MMX}
             in_rol_x,
-            in_rol_x_x,
+            in_rol_x_y,
             in_ror_x,
-            in_ror_x_x:
+            in_ror_x_y:
               second_rox;
             in_sar_x,
             in_sar_x_y:
@@ -741,10 +741,10 @@ implementation
         location_copy(location,op1.location);
         case inlinenumber of
           in_ror_x,
-          in_ror_x_x:
+          in_ror_x_y:
             op:=OP_ROR;
           in_rol_x,
-          in_rol_x_x:
+          in_rol_x_y:
             op:=OP_ROL;
         end;
         location_force_reg(current_asmdata.CurrAsmList,location,location.size,false);

+ 8 - 7
compiler/ncgrtti.pas

@@ -452,7 +452,7 @@ implementation
           end;
           { we need to align by Tconstptruint here to satisfy the alignment rules set by
             records: in the typinfo unit we overlay a TTypeData record on this data, which at
-            the innermost variant record needs an alignment of TConstPtrUint due to e.g. 
+            the innermost variant record needs an alignment of TConstPtrUint due to e.g.
             the "CompType" member for tkSet (also the "BaseType" member for tkEnumeration).
             We need to adhere to this, otherwise things will break.
             Note that other code (e.g. enumdef_rtti_calcstringtablestart()) relies on the
@@ -490,7 +490,8 @@ implementation
               (otUByte{otNone},
                otUByte,otUWord,otULong,otUByte{otNone},
                otSByte,otSWord,otSLong,otUByte{otNone},
-               otUByte,otSByte,otSWord,otSLong,otSByte,
+               otUByte,otUWord,otULong,otUByte,
+               otSByte,otSWord,otSLong,otSByte,
                otUByte,otUWord,otUByte);
           begin
             write_header(def,typekind);
@@ -523,7 +524,7 @@ implementation
                 { high }
                 current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_64bit(def.high.svalue));
               end;
-            pasbool:
+            pasbool8:
                 dointeger(tkBool);
             uchar:
                 dointeger(tkChar);
@@ -698,18 +699,18 @@ implementation
                  potype_class_constructor: methodkind:=mkClassConstructor;
                  potype_class_destructor: methodkind:=mkClassDestructor;
                  potype_operator: methodkind:=mkOperatorOverload;
-                 potype_procedure: 
-                   if po_classmethod in def.procoptions then 
+                 potype_procedure:
+                   if po_classmethod in def.procoptions then
                      methodkind:=mkClassProcedure
                    else
                      methodkind:=mkProcedure;
                  potype_function:
-                   if po_classmethod in def.procoptions then 
+                   if po_classmethod in def.procoptions then
                      methodkind:=mkClassFunction
                    else
                      methodkind:=mkFunction;
                else
-                 begin                   
+                 begin
                    if def.returndef = voidtype then
                      methodkind:=mkProcedure
                    else

+ 1 - 33
compiler/ncgutil.pas

@@ -159,8 +159,6 @@ interface
 
     function getprocalign : shortint;
 
-    procedure gen_pic_helpers(list : TAsmList);
-
     procedure gen_fpc_dummy(list : TAsmList);
 
     procedure InsertInterruptTable;
@@ -2535,7 +2533,7 @@ implementation
             sectype:=sec_bss;
           end;
         maybe_new_object_file(list);
-        if sym.section<>'' then
+        if vo_has_section in sym.varoptions then
           new_section(list,sec_user,sym.section,varalign)
         else
           new_section(list,sectype,lower(sym.mangledname),varalign);
@@ -3105,36 +3103,6 @@ implementation
       end;
 
 
-    procedure gen_pic_helpers(list : TAsmList);
-{$ifdef i386}
-      var
-        href : treference;
-{$endif i386}
-      begin
-        { if other cpus require such helpers as well, it can be solved more cleanly }
-{$ifdef i386}
-        if current_module.requires_ebx_pic_helper then
-          begin
-            new_section(list,sec_code,'fpc_geteipasebx',0);
-            list.concat(tai_symbol.Createname('fpc_geteipasebx',AT_FUNCTION,getprocalign));
-            reference_reset(href,sizeof(pint));
-            href.base:=NR_ESP;
-            list.concat(taicpu.op_ref_reg(A_MOV,S_L,href,NR_EBX));
-            list.concat(taicpu.op_none(A_RET,S_NO));
-          end;
-        if current_module.requires_ecx_pic_helper then
-          begin
-            new_section(list,sec_code,'fpc_geteipasecx',0);
-            list.concat(tai_symbol.Createname('fpc_geteipasecx',AT_FUNCTION,getprocalign));
-            reference_reset(href,sizeof(pint));
-            href.base:=NR_ESP;
-            list.concat(taicpu.op_ref_reg(A_MOV,S_L,href,NR_ECX));
-            list.concat(taicpu.op_none(A_RET,S_NO));
-          end;
-{$endif i386}
-      end;
-
-
     procedure gen_fpc_dummy(list : TAsmList);
       begin
 {$ifdef i386}

+ 8 - 8
compiler/ncnv.pas

@@ -913,7 +913,7 @@ implementation
             addstatement(newstat,restemp);
             addstatement(newstat,ccallnode.createintern('fpc_'+chartype+'array_to_shortstr',
               ccallparanode.create(cordconstnode.create(
-                ord(tarraydef(left.resultdef).lowrange=0),booltype,false),
+                ord(tarraydef(left.resultdef).lowrange=0),pasbool8type,false),
               ccallparanode.create(left,ccallparanode.create(
               ctemprefnode.create(restemp),nil)))));
             addstatement(newstat,ctempdeletenode.create_normal_temp(restemp));
@@ -924,7 +924,7 @@ implementation
           result:=ccallnode.createinternres(
             'fpc_'+chartype+'array_to_'+tstringdef(resultdef).stringtypname,
             ccallparanode.create(cordconstnode.create(
-               ord(tarraydef(left.resultdef).lowrange=0),booltype,false),
+               ord(tarraydef(left.resultdef).lowrange=0),pasbool8type,false),
              ccallparanode.create(left,nil)),resultdef);
         left:=nil;
       end;
@@ -1377,7 +1377,7 @@ implementation
         if assigned(tobjectdef(left.resultdef).iidstr) then
           begin
             if not(oo_has_valid_guid in tobjectdef(left.resultdef).objectoptions) then
-              CGMessage1(type_interface_has_no_guid,tobjectdef(left.resultdef).typename);
+              CGMessage1(type_e_interface_has_no_guid,tobjectdef(left.resultdef).typename);
             result:=cstringconstnode.createstr(tobjectdef(left.resultdef).iidstr^);
             tstringconstnode(result).changestringtype(cshortstringtype);
           end;
@@ -1389,7 +1389,7 @@ implementation
         if assigned(tobjectdef(left.resultdef).iidguid) then
           begin
             if not(oo_has_valid_guid in tobjectdef(left.resultdef).objectoptions) then
-              CGMessage1(type_interface_has_no_guid,tobjectdef(left.resultdef).typename);
+              CGMessage1(type_e_interface_has_no_guid,tobjectdef(left.resultdef).typename);
             result:=cguidconstnode.create(tobjectdef(left.resultdef).iidguid^);
           end;
       end;
@@ -2463,7 +2463,7 @@ implementation
                   fname:='int64_to_'
                 else
                   { we can't do better currently }
-                  fname:='int64_to_';
+                  fname:='qword_to_';
               end
             else
               { other integers are supposed to be 32 bit }
@@ -3347,7 +3347,7 @@ implementation
               CGMessage1(type_e_class_or_cominterface_type_expected,left.resultdef.typename);
             case nodetype of
               isn:
-                resultdef:=booltype;
+                resultdef:=pasbool8type;
               asn:
                 resultdef:=tclassrefdef(right.resultdef).pointeddef;
             end;
@@ -3361,7 +3361,7 @@ implementation
 
             case nodetype of
               isn:
-                resultdef:=booltype;
+                resultdef:=pasbool8type;
               asn:
                 resultdef:=right.resultdef;
             end;
@@ -3386,7 +3386,7 @@ implementation
                     if assigned(tobjectdef(right.resultdef).iidguid) then
                       begin
                         if not(oo_has_valid_guid in tobjectdef(right.resultdef).objectoptions) then
-                          CGMessage1(type_interface_has_no_guid,tobjectdef(right.resultdef).typename);
+                          CGMessage1(type_e_interface_has_no_guid,tobjectdef(right.resultdef).typename);
                         hp:=cguidconstnode.create(tobjectdef(right.resultdef).iidguid^);
                         right.free;
                         right:=hp;

+ 17 - 12
compiler/nflw.pas

@@ -457,7 +457,7 @@ implementation
           one }
         hp:=cwhilerepeatnode.create(
           { repeat .. until false }
-          cordconstnode.create(0,booltype,false),innerloop,false,true);
+          cordconstnode.create(0,pasbool8type,false),innerloop,false,true);
         addstatement(outerloopbodystatement,hp);
 
         { create the outer repeat/until and add it to the the main body }
@@ -1070,10 +1070,11 @@ implementation
          if codegenerror then
            exit;
 
-         if not is_boolean(left.resultdef) then
+         if not(is_boolean(left.resultdef)) and
+           not(is_typeparam(left.resultdef)) then
            begin
              if left.resultdef.typ=variantdef then
-               inserttypeconv(left,booltype)
+               inserttypeconv(left,pasbool8type)
              else
                CGMessage1(type_e_boolean_expr_expected,left.resultdef.typename);
            end;
@@ -1310,7 +1311,7 @@ implementation
             end;
         if not is_constboolnode(condition) then
             aktstate.store_fact(condition,
-             cordconstnode.create(byte(checknegate),booltype,true))
+             cordconstnode.create(byte(checknegate),pasbool8type,true))
         else
             condition.destroy;
     end;
@@ -1382,10 +1383,11 @@ implementation
          if codegenerror then
            exit;
 
-         if not is_boolean(left.resultdef) then
+         if not(is_boolean(left.resultdef)) and
+           not(is_typeparam(left.resultdef)) then
            begin
              if left.resultdef.typ=variantdef then
-               inserttypeconv(left,booltype)
+               inserttypeconv(left,pasbool8type)
              else
                Message1(type_e_boolean_expr_expected,left.resultdef.typename);
            end;
@@ -1569,10 +1571,17 @@ implementation
 
 
     function texitnode.pass_typecheck:tnode;
+      var
+        newstatement : tstatementnode;
       begin
         result:=nil;
         if assigned(left) then
-          typecheckpass(left);
+          begin
+             result:=internalstatements(newstatement);
+             addstatement(newstatement,left);
+             left:=nil;
+             addstatement(newstatement,self.getcopy);
+          end;
         resultdef:=voidtype;
       end;
 
@@ -1582,11 +1591,7 @@ implementation
          result:=nil;
          expectloc:=LOC_VOID;
          if assigned(left) then
-           begin
-              firstpass(left);
-              if codegenerror then
-               exit;
-           end;
+           internalerror(2011052801);
       end;
 
 

+ 101 - 11
compiler/ninl.pas

@@ -314,7 +314,8 @@ implementation
             scurrency,
             s64bit:
               procname := procname + 'int64';
-            pasbool,bool8bit,bool16bit,bool32bit,bool64bit:
+            pasbool8,pasbool16,pasbool32,pasbool64,
+            bool8bit,bool16bit,bool32bit,bool64bit:
               procname := procname + 'bool';
 {$endif}
             else
@@ -511,7 +512,10 @@ implementation
                       readfunctype:=s64currencytype;
                       is_real:=true;
                     end;
-                  pasbool,
+                  pasbool8,
+                  pasbool16,
+                  pasbool32,
+                  pasbool64,
                   bool8bit,
                   bool16bit,
                   bool32bit,
@@ -524,7 +528,7 @@ implementation
                     else
                       begin
                         name := procprefixes[do_read]+'boolean';
-                        readfunctype:=booltype;
+                        readfunctype:=pasbool8type;
                       end
                   else
                     begin
@@ -746,7 +750,7 @@ implementation
                   { zero-based                                       }
                   if para.left.resultdef.typ=arraydef then
                     para := ccallparanode.create(cordconstnode.create(
-                      ord(tarraydef(para.left.resultdef).lowrange=0),booltype,false),para);
+                      ord(tarraydef(para.left.resultdef).lowrange=0),pasbool8type,false),para);
                   { create the call statement }
                   addstatement(Tstatementnode(newstatement),
                     ccallnode.createintern(name,para));
@@ -1521,6 +1525,74 @@ implementation
         end;
 
 
+      function handle_const_rox : tnode;
+        var
+          vl,vl2    : TConstExprInt;
+          bits,shift: integer;
+          def : tdef;
+        begin
+          result:=nil;
+          if (left.nodetype=ordconstn) or ((left.nodetype=callparan) and (tcallparanode(left).left.nodetype=ordconstn)) then
+            begin
+              if (left.nodetype=callparan) and
+                 assigned(tcallparanode(left).right) then
+                begin
+                  if (tcallparanode(tcallparanode(left).right).left.nodetype=ordconstn) then
+                    begin
+                      def:=tcallparanode(tcallparanode(left).right).left.resultdef;
+                      vl:=tordconstnode(tcallparanode(left).left).value;
+                      vl2:=tordconstnode(tcallparanode(tcallparanode(left).right).left).value;
+                    end
+                  else
+                    exit;
+                end
+              else
+                begin
+                  def:=left.resultdef;
+                  vl:=1;
+                  vl2:=tordconstnode(left).value;
+                end;
+
+              bits:=def.size*8;
+              shift:=vl.svalue and (bits-1);
+{$push}
+{$r-,q-}
+              if shift=0 then
+                result:=cordconstnode.create(vl2.svalue,def,false)
+              else
+                case inlinenumber of
+                  in_ror_x,in_ror_x_y:
+                    case def.size of
+                      1:
+                        result:=cordconstnode.create(RorByte(Byte(vl2.svalue),shift),def,false);
+                      2:
+                        result:=cordconstnode.create(RorWord(Word(vl2.svalue),shift),def,false);
+                      4:
+                        result:=cordconstnode.create(RorDWord(DWord(vl2.svalue),shift),def,false);
+                      8:
+                        result:=cordconstnode.create(RorQWord(QWord(vl2.svalue),shift),def,false);
+                      else
+                        internalerror(2011061903);
+                    end;
+                  in_rol_x,in_rol_x_y:
+                    case def.size of
+                      1:
+                        result:=cordconstnode.create(RolByte(Byte(vl2.svalue),shift),def,false);
+                      2:
+                        result:=cordconstnode.create(RolWord(Word(vl2.svalue),shift),def,false);
+                      4:
+                        result:=cordconstnode.create(RolDWord(DWord(vl2.svalue),shift),def,false);
+                      8:
+                        result:=cordconstnode.create(RolQWord(QWord(vl2.svalue),shift),def,false);
+                      else
+                        internalerror(2011061902);
+                    end;
+                  else
+                    internalerror(2011061901);
+                  end;
+            end;
+        end;
+
       var
         hp        : tnode;
         vl,vl2    : TConstExprInt;
@@ -1567,7 +1639,7 @@ implementation
                    else
                      hp:=create_simplified_ord_const(sqr(vl.uvalue),resultdef,forinline);
                  in_const_odd :
-                   hp:=cordconstnode.create(qword(odd(int64(vl))),booltype,true);
+                   hp:=cordconstnode.create(qword(odd(int64(vl))),pasbool8type,true);
                  in_const_swap_word :
                    hp:=cordconstnode.create((vl and $ff) shl 8+(vl shr 8),left.resultdef,true);
                  in_const_swap_long :
@@ -1623,19 +1695,32 @@ implementation
                     orddef :
                       begin
                         case torddef(left.resultdef).ordtype of
-                          pasbool,
+                          pasbool8,
                           uchar:
                             begin
                               { change to byte() }
                               result:=ctypeconvnode.create_internal(left,u8inttype);
                               left:=nil;
                             end;
+                          pasbool16,
                           uwidechar :
                             begin
                               { change to word() }
                               result:=ctypeconvnode.create_internal(left,u16inttype);
                               left:=nil;
                             end;
+                          pasbool32 :
+                            begin
+                              { change to dword() }
+                              result:=ctypeconvnode.create_internal(left,u32inttype);
+                              left:=nil;
+                            end;
+                          pasbool64 :
+                            begin
+                              { change to qword() }
+                              result:=ctypeconvnode.create_internal(left,u64inttype);
+                              left:=nil;
+                            end;
                           bool8bit:
                             begin
                               { change to shortint() }
@@ -1931,6 +2016,11 @@ implementation
                 begin
                   result:=handle_const_sar;
                 end;
+              in_rol_x,
+              in_rol_x_y,
+              in_ror_x,
+              in_ror_x_y :
+                result:=handle_const_rox;
             end;
           end;
       end;
@@ -2284,7 +2374,7 @@ implementation
                     in procvar handling between FPC and Delphi handling, so
                     handle specially }
                   set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
-                  resultdef:=booltype;
+                  resultdef:=pasbool8type;
                 end;
 
               in_ofs_x :
@@ -2621,8 +2711,8 @@ implementation
                   set_varstate(left,vs_read,[vsf_must_be_valid]);
                   resultdef:=left.resultdef;
                 end;
-              in_rol_x_x,
-              in_ror_x_x,
+              in_rol_x_y,
+              in_ror_x_y,
               in_sar_x_y:
                 begin
                   set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
@@ -3040,9 +3130,9 @@ implementation
              expectloc:=tcallparanode(left).left.expectloc;
            end;
          in_rol_x,
-         in_rol_x_x,
+         in_rol_x_y,
          in_ror_x,
-         in_ror_x_x,
+         in_ror_x_y,
          in_sar_x,
          in_sar_x_y,
          in_bsf_x,

+ 18 - 15
compiler/nmat.pas

@@ -111,7 +111,6 @@ implementation
 
     function tmoddivnode.simplify(forinline : boolean):tnode;
       var
-        t : tnode;
         rv,lv : tconstexprint;
       begin
         result:=nil;
@@ -143,12 +142,10 @@ implementation
 
             case nodetype of
               modn:
-                t:=create_simplified_ord_const(lv mod rv,resultdef,forinline);
+                result:=create_simplified_ord_const(lv mod rv,resultdef,forinline);
               divn:
-                t:=create_simplified_ord_const(lv div rv,resultdef,forinline);
+                result:=create_simplified_ord_const(lv div rv,resultdef,forinline);
             end;
-            result:=t;
-            exit;
          end;
       end;
 
@@ -460,8 +457,6 @@ implementation
  ****************************************************************************}
 
     function tshlshrnode.simplify(forinline : boolean):tnode;
-      var
-        t : tnode;
       begin
         result:=nil;
         { constant folding }
@@ -469,12 +464,10 @@ implementation
           begin
              case nodetype of
                 shrn:
-                  t:=create_simplified_ord_const(tordconstnode(left).value shr tordconstnode(right).value,resultdef,forinline);
+                  result:=create_simplified_ord_const(tordconstnode(left).value shr tordconstnode(right).value,resultdef,forinline);
                 shln:
-                  t:=create_simplified_ord_const(tordconstnode(left).value shl tordconstnode(right).value,resultdef,forinline);
+                  result:=create_simplified_ord_const(tordconstnode(left).value shl tordconstnode(right).value,resultdef,forinline);
              end;
-             result:=t;
-             exit;
           end;
 
       end;
@@ -558,11 +551,18 @@ implementation
         procname: string[31];
       begin
         result := nil;
+        { Normally already done below, but called again,
+          just in case it is called directly }
+        firstpass(left);
         { otherwise create a call to a helper }
+        if is_signed(left.resultdef) then
+          procname:='int64'
+        else
+          procname:='qword';
         if nodetype = shln then
-          procname := 'fpc_shl_int64'
+          procname := 'fpc_shl_'+procname
         else
-          procname := 'fpc_shr_int64';
+          procname := 'fpc_shr_'+procname;
         { this order of parameters works at least for the arm,
           however it should work for any calling conventions (FK) }
         result := ccallnode.createintern(procname,ccallparanode.create(right,
@@ -884,14 +884,17 @@ implementation
              v:=tordconstnode(left).value;
              def:=left.resultdef;
              case torddef(left.resultdef).ordtype of
-               pasbool,
+               pasbool8,
+               pasbool16,
+               pasbool32,
+               pasbool64,
                bool8bit,
                bool16bit,
                bool32bit,
                bool64bit:
                  begin
                    v:=byte(not(boolean(int64(v))));
-                   if (torddef(left.resultdef).ordtype<>pasbool) then
+                   if is_cbool(left.resultdef) then
                      v:=-v;
                  end;
                uchar,

+ 3 - 4
compiler/nobj.pas

@@ -266,7 +266,7 @@ implementation
             end;
 
           { compare parameter types only, no specifiers yet }
-          hasequalpara:=(compare_paras(vmtpd.paras,pd.paras,cp_none,[cpo_ignoreuniv])>=te_equal);
+          hasequalpara:=(compare_paras(vmtpd.paras,pd.paras,cp_none,[cpo_ignoreuniv,cpo_ignorehidden])>=te_equal);
 
           { check that we are not trying to override a final method }
           if (po_finalmethod in vmtpd.procoptions) and
@@ -352,7 +352,7 @@ implementation
 
                   { All parameter specifiers and some procedure the flags have to match
                     except abstract and override }
-                  if (compare_paras(vmtpd.paras,pd.paras,cp_all,[cpo_ignoreuniv])<te_equal) or
+                  if (compare_paras(vmtpd.paras,pd.paras,cp_all,[cpo_ignoreuniv,cpo_ignorehidden])<te_equal) or
                      (vmtpd.proccalloption<>pd.proccalloption) or
                      (vmtpd.proctypeoption<>pd.proctypeoption) or
                      ((vmtpd.procoptions*po_comp)<>(pd.procoptions*po_comp)) then
@@ -1161,8 +1161,7 @@ implementation
                (pd.visibility=vis_published) then
               begin
                 current_asmdata.getdatalabel(l);
-
-                current_asmdata.asmlists[al_typedconsts].concat(cai_align.create(const_align(sizeof(pint))));
+                new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,l.name,const_align(sizeof(pint)));
                 current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l));
                 current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(length(tsym(p).realname)));
                 current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create(tsym(p).realname));

+ 6 - 6
compiler/nset.pas

@@ -213,7 +213,7 @@ implementation
 
       begin
          result:=nil;
-         resultdef:=booltype;
+         resultdef:=pasbool8type;
          typecheckpass(right);
          set_varstate(right,vs_read,[vsf_must_be_valid]);
          if codegenerror then
@@ -256,7 +256,7 @@ implementation
              }
              if  (
                    (left.resultdef.typ = orddef) and not
-                   (torddef(left.resultdef).ordtype in [s8bit,u8bit,uchar,pasbool,bool8bit])
+                   (torddef(left.resultdef).ordtype in [s8bit,u8bit,uchar,pasbool8,bool8bit])
                  )
                 or
                  (
@@ -294,7 +294,7 @@ implementation
             ((right.nodetype = setconstn) and
              (tnormalset(tsetconstnode(right).value_set^) = [])) then
           begin
-            t:=cordconstnode.create(0,booltype,false);
+            t:=cordconstnode.create(0,pasbool8type,false);
             typecheckpass(t);
             result:=t;
             exit;
@@ -321,10 +321,10 @@ implementation
                  { into account                                             }
                  if Tordconstnode(left).value.signed then
                    t:=cordconstnode.create(byte(tordconstnode(left).value.svalue in Tsetconstnode(right).value_set^),
-                     booltype,true)
+                     pasbool8type,true)
                  else
                    t:=cordconstnode.create(byte(tordconstnode(left).value.uvalue in Tsetconstnode(right).value_set^),
-                     booltype,true);
+                     pasbool8type,true);
                  typecheckpass(t);
                  result:=t;
                  exit;
@@ -334,7 +334,7 @@ implementation
                  if (Tordconstnode(left).value<int64(tsetdef(right.resultdef).setbase)) or
                     (Tordconstnode(left).value>int64(Tsetdef(right.resultdef).setmax)) then
                    begin
-                     t:=cordconstnode.create(0, booltype, true);
+                     t:=cordconstnode.create(0, pasbool8type, true);
                      typecheckpass(t);
                      result:=t;
                      exit;

+ 134 - 10
compiler/ogbase.pas

@@ -397,7 +397,7 @@ interface
         FIsVar  : boolean;
         FMangledName : string;
       public
-        constructor create(AList:TFPHashObjectList;const AName:string;AOrdNr:longint;AIsVar:boolean);
+        constructor create(AList:TFPHashObjectList;const AName,AMangledName:string;AOrdNr:longint;AIsVar:boolean);
         property OrdNr: longint read FOrdNr;
         property MangledName: string read FMangledName;
         property IsVar: boolean read FIsVar;
@@ -413,6 +413,7 @@ interface
         FCurrExeSec       : TExeSection;
         FExeSectionList   : TFPHashObjectList;
         Fzeronr           : longint;
+        Fvaluesnr         : longint;
         { Symbols }
         FExeSymbolList    : TFPHashObjectList;
         FUnresolvedExeSymbols : TFPObjectList;
@@ -438,7 +439,7 @@ interface
         function  writeData:boolean;virtual;abstract;
         property CExeSection:TExeSectionClass read FCExeSection write FCExeSection;
         property CObjData:TObjDataClass read FCObjData write FCObjData;
-        procedure Order_ObjSectionList(ObjSectionList : TFPObjectList);virtual;
+        procedure Order_ObjSectionList(ObjSectionList : TFPObjectList; const aPattern:string);virtual;
       public
         CurrDataPos  : aword;
         MaxMemPos    : qword;
@@ -450,6 +451,7 @@ interface
         procedure Load_Start;virtual;
         procedure Load_EntryName(const aname:string);virtual;
         procedure Load_Symbol(const aname:string);virtual;
+        procedure Load_ProvideSymbol(const aname:string);virtual;
         procedure Load_IsSharedLibrary;
         procedure Load_ImageBase(const avalue:string);
         procedure Order_Start;virtual;
@@ -457,7 +459,9 @@ interface
         procedure Order_ExeSection(const aname:string);virtual;
         procedure Order_Align(const avalue:string);virtual;
         procedure Order_Zeros(const avalue:string);virtual;
+        procedure Order_Values(bytesize : aword; const avalue:string);virtual;
         procedure Order_Symbol(const aname:string);virtual;
+        procedure Order_ProvideSymbol(const aname:string);virtual;
         procedure Order_EndExeSection;virtual;
         procedure Order_ObjSection(const aname:string);virtual;
         procedure MemPos_Start;virtual;
@@ -549,9 +553,15 @@ implementation
           internalerror(200603016);
         if not assigned(aobjsec) then
           internalerror(200603017);
-        if (bind in [AB_EXTERNAL,AB_LAZY]) then
+        if (bind in [AB_EXTERNAL,AB_LAZY]) or
+          { Put all COMMON to GLOBAL in step 3 of
+            TExeOutput.ResolveSymbols }
+           ((abind=AB_GLOBAL) and (bind=AB_COMMON)) then
           begin
-            bind:=abind;
+            { Do not change the AB_TYPE of common symbols yet }
+            { This will be done in FixupSymbols }
+            if (pass<>0) or (bind<>AB_COMMON) then
+              bind:=abind;
             typ:=atyp;
           end
         else
@@ -911,7 +921,11 @@ implementation
 { TODO: Fix sec_rodata_norel be read-only/constant}
           {roData_norel} [oso_Data,oso_load,oso_write,oso_keep],
           {bss} [oso_load,oso_write,oso_keep],
-          {threadvar} [oso_load,oso_write],
+          {threadvar} [oso_load,oso_write
+{$ifdef FPC_USE_TLS_DIRECTORY}
+                       ,oso_keep
+{$endif FPC_USE_TLS_DIRECTORY}
+          ],
           {pdata} [oso_load,oso_readonly,oso_keep],
           {stub} [oso_Data,oso_load,oso_readonly,oso_executable],
           {data_nonlazy}  [oso_Data,oso_load,oso_write],
@@ -1467,12 +1481,13 @@ implementation
                                 TImportSymbol
 ****************************************************************************}
 
-    constructor TImportSymbol.create(AList:TFPHashObjectList;const AName:string;AOrdNr:longint;AIsVar:boolean);
+    constructor TImportSymbol.create(AList:TFPHashObjectList;
+            const AName,AMangledName:string;AOrdNr:longint;AIsVar:boolean);
       begin
         inherited Create(AList, AName);
         FOrdNr:=AOrdNr;
         FIsVar:=AIsVar;
-        FMangledName:=AName;
+        FMangledName:=AMangledName;
         { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. }
         { This allows to import VC++ mangled names from DLLs. }
         if target_info.system in systems_all_windows then
@@ -1584,7 +1599,7 @@ implementation
 
     procedure TExeOutput.Load_EntryName(const aname:string);
       begin
-        EntryName:=aname;
+        FEntryName:=aname;
       end;
 
 
@@ -1620,6 +1635,15 @@ implementation
         internalObjData.SymbolDefine(aname,AB_GLOBAL,AT_FUNCTION);
       end;
 
+    procedure TExeOutput.Load_ProvideSymbol(const aname:string);
+      begin
+        if assigned(ExeSymbolList.Find(aname)) then
+          exit;
+        internalObjData.createsection('*'+aname,0,[]);
+        // Use AB_COMMON to avoid muliple defined complaints
+        internalObjData.SymbolDefine(aname,AB_COMMON,AT_DATA);
+      end;
+
 
     procedure TExeOutput.Order_Start;
       begin
@@ -1674,7 +1698,7 @@ implementation
               end;
           end;
         { Order list if needed }
-        Order_ObjSectionList(TmpObjSectionList);
+        Order_ObjSectionList(TmpObjSectionList,aname);
         { Add the (ordered) list to the current ExeSection }
         for i:=0 to TmpObjSectionList.Count-1 do
           begin
@@ -1685,7 +1709,7 @@ implementation
       end;
 
 
-    procedure TExeOutput.Order_ObjSectionList(ObjSectionList : TFPObjectList);
+    procedure TExeOutput.Order_ObjSectionList(ObjSectionList : TFPObjectList; const aPattern:string);
       begin
       end;
 
@@ -1700,6 +1724,19 @@ implementation
         CurrExeSec.AddObjSection(ObjSection);
       end;
 
+    procedure TExeOutput.Order_ProvideSymbol(const aname:string);
+      var
+        ObjSection : TObjSection;
+      begin
+        ObjSection:=internalObjData.findsection('*'+aname);
+        if not assigned(ObjSection) then
+          internalerror(200603041);
+        { Only include this section if the symbol doesn't
+          exist otherwisee }
+        if not assigned(ExeSymbolList.Find(aname)) then
+          CurrExeSec.AddObjSection(ObjSection);
+      end;
+
 
     procedure TExeOutput.Order_Align(const avalue:string);
       var
@@ -1740,6 +1777,93 @@ implementation
         CurrExeSec.AddObjSection(objsec);
       end;
 
+    procedure TExeOutput.Order_Values(bytesize : aword; const avalue:string);
+      const
+        MAXVAL = 128;
+      var
+        bytevalues : array[0..MAXVAL-1] of byte;
+        twobytevalues : array[0..MAXVAL-1] of word;
+        fourbytevalues : array[0..MAXVAL-1] of dword;
+        eightbytevalues : array[0..MAXVAL-1] of qword;
+        allvals, oneval : string;
+        len, commapos : longint;
+        indexpos, code  : integer;
+        anumval : qword;
+        signedval : int64;
+        objsec : TObjSection;
+      begin
+        indexpos:=0;
+        allvals:=avalue;
+        repeat
+          commapos:=pos(',',allvals);
+          if commapos>0 then
+            begin
+              oneval:=trim(copy(allvals,1,commapos-1));
+              allvals:=copy(allvals,commapos+1,length(allvals));
+            end
+          else
+            begin
+              oneval:=trim(allvals);
+              allvals:='';
+            end;
+          if oneval<>'' then
+            begin
+              if oneval[1]='-' then
+                begin
+                  val(oneval,signedval,code);
+                  anumval:=qword(signedval);
+                end
+              else
+                val(oneval,anumval,code);
+              if code<>0 then
+                Comment(V_Error,'Invalid number '+avalue)
+              else
+                begin
+                  if (indexpos<MAXVAL) then
+                    begin
+                      if source_info.endian<>target_info.endian then
+                        swapendian(anumval);
+                      { No range checking here }
+
+                      if bytesize=1 then
+                        bytevalues[indexpos]:=byte(anumval)
+                      else if bytesize=2 then
+                        twobytevalues[indexpos]:=word(anumval)
+                      else if bytesize=4 then
+                        fourbytevalues[indexpos]:=dword(anumval)
+                      else if bytesize=8 then
+                        eightbytevalues[indexpos]:=anumval;
+                      inc(indexpos);
+                    end
+                  else
+                    Comment(V_Error,'Buffer overrun in Order_values');
+                end;
+            end;
+        until allvals='';
+        if indexpos=0 then
+          begin
+            Comment(V_Error,'Invalid number '+avalue);
+            exit;
+          end;
+        if indexpos=MAXVAL then
+          begin
+            Comment(V_Error,'Too many values '+avalue);
+            internalerror(200602254);
+          end;
+        len:=bytesize*indexpos;
+        inc(Fvaluesnr);
+        objsec:=internalObjData.createsection('*values'+tostr(Fvaluesnr),0,CurrExeSec.SecOptions+[oso_Data,oso_keep]);
+        if bytesize=1 then
+          internalObjData.writebytes(bytevalues,len)
+        else if bytesize=2 then
+          internalObjData.writebytes(twobytevalues,len)
+        else if bytesize=4 then
+          internalObjData.writebytes(fourbytevalues,len)
+        else if bytesize=8 then
+          internalObjData.writebytes(eightbytevalues,len);
+        CurrExeSec.AddObjSection(objsec);
+      end;
+
 
     procedure TExeOutput.MemPos_Start;
       begin

+ 119 - 14
compiler/ogcoff.pas

@@ -235,7 +235,7 @@ interface
          procedure ExeSectionList_write_data(p:TObject;arg:pointer);
        protected
          function writedata:boolean;override;
-         procedure Order_ObjSectionList(ObjSectionList : TFPObjectList);override;
+         procedure Order_ObjSectionList(ObjSectionList : TFPObjectList;const aPattern:string);override;
        public
          constructor createcoff(awin32:boolean);
          procedure MemPos_Header;override;
@@ -484,6 +484,14 @@ implementation
          aux     : byte;
        end;
 
+       { This is defined in rtl/win/sysos.inc source }
+       tlsdirectory=packed record
+         data_start, data_end : PUInt;
+         index_pointer, callbacks_pointer : PUInt;
+         zero_fill_size : dword;
+         flags : dword;
+       end;
+
      const
        SymbolMaxGrow = 200*sizeof(coffsymbol);
        StrsMaxGrow   = 8192;
@@ -1017,6 +1025,8 @@ const pemagic : array[0..3] of byte = (
         createsection(sec_code);
         createsection(sec_data);
         createsection(sec_bss);
+        if tf_section_threadvars in target_info.flags then
+          createsection(sec_threadvar);
       end;
 
 
@@ -2097,12 +2107,16 @@ const pemagic : array[0..3] of byte = (
             else
               sechdr.vsize:=mempos;
 
-            { sechdr.dataSize is size of initilized data. For .bss section it must be zero }
-            if (Name <> '.bss') then
-              sechdr.dataSize:=Size;
-            if (sechdr.dataSize>0) and
-               (oso_data in SecOptions) then
-              sechdr.datapos:=datapos;
+            { sechdr.dataSize is size of initilized data. Must be zero for sections that
+              do not contain one.
+              TODO: In Windows it must be rounded up to FileAlignment
+              (so it can be greater than VirtualSize) }
+            if (oso_data in SecOptions) then
+              begin
+                sechdr.dataSize:=Size;
+                if (Size>0) then
+                  sechdr.datapos:=datapos;
+              end;
             sechdr.nrelocs:=0;
             sechdr.relocpos:=0;
             if win32 then
@@ -2112,6 +2126,10 @@ const pemagic : array[0..3] of byte = (
                   sechdr.flags:=peencodesechdrflags(SecOptions,SecAlign) or PE_SCN_MEM_NOT_PAGED
                 else
                   sechdr.flags:=peencodesechdrflags(SecOptions,SecAlign);
+                { some flags are invalid in executables, reset them }
+                sechdr.flags:=sechdr.flags and
+                  not(PE_SCN_LNK_INFO or PE_SCN_LNK_REMOVE or
+                      PE_SCN_LNK_COMDAT or PE_SCN_ALIGN_MASK);
               end
             else
               sechdr.flags:=djencodesechdrflags(SecOptions);
@@ -2222,7 +2240,9 @@ const pemagic : array[0..3] of byte = (
         textExeSec,
         dataExeSec,
         bssExeSec,
-        idataExeSec : TExeSection;
+        idataExeSec,
+        tlsExeSec : TExeSection;
+        tlsdir : TlsDirectory;
         hassymbols,
         writeDbgStrings : boolean;
 
@@ -2238,6 +2258,88 @@ const pemagic : array[0..3] of byte = (
            end;
         end;
 
+        procedure UpdateImports;
+        var
+          exesec: TExeSection;
+          objsec, iat_start, iat_end, ilt_start: TObjSection;
+          i: longint;
+        begin
+          exesec:=FindExeSection('.idata');
+          if exesec=nil then
+            exit;
+          iat_start:=nil;
+          iat_end:=nil;
+          ilt_start:=nil;
+          for i:=0 to exesec.ObjSectionList.Count-1 do
+            begin
+              objsec:=TObjSection(exesec.ObjSectionList[i]);
+              if (ilt_start=nil) and (Pos('.idata$4',objsec.Name)=1) then
+                ilt_start:=objsec;
+              if Pos('.idata$5',objsec.Name)=1 then
+                begin
+                  if iat_start=nil then
+                    iat_start:=objsec;
+                end
+              else
+                if Assigned(iat_start) then
+                  begin
+                    iat_end:=objsec;
+                    Break;
+                  end;
+            end;
+
+          peoptheader.DataDirectory[PE_DATADIR_IDATA].vaddr:=exesec.mempos;
+          if Assigned(ilt_start) then
+            peoptheader.DataDirectory[PE_DATADIR_IDATA].size:=ilt_start.mempos-exesec.mempos
+          else  { should not happen }
+            peoptheader.DataDirectory[PE_DATADIR_IDATA].size:=exesec.Size;
+
+          if Assigned(iat_start) and Assigned(iat_end) then
+            begin
+              peoptheader.DataDirectory[PE_DATADIR_IMPORTADDRESSTABLE].vaddr:=iat_start.mempos;
+              peoptheader.DataDirectory[PE_DATADIR_IMPORTADDRESSTABLE].size:=iat_end.mempos-iat_start.mempos;
+            end;
+        end;
+
+        procedure UpdateTlsDataDir;
+        var
+          {callbacksection : TExeSection;}
+          tlsexesymbol: TExeSymbol;
+          tlssymbol: TObjSymbol;
+          callbackexesymbol: TExeSymbol;
+          callbacksymbol: TObjSymbol;
+        begin
+          { according to GNU ld,
+            the callback routines should be placed into .CRT$XL*
+            sections, and the thread local variables in .tls
+            __tls_start__ and __tls_end__ symbols
+            should be used for the initialized part,
+            which we do not support yet. }
+          { For now, we only pass the address of the __tls_used
+            asm symbol into PE_DATADIR_TLS with the correct
+            size of this table (different for win32/win64 }
+          tlsexesymbol:=texesymbol(ExeSymbolList.Find(
+            target_info.Cprefix+'_tls_used'));
+          if assigned(tlsexesymbol) then
+            begin
+              tlssymbol:=tlsexesymbol.ObjSymbol;
+              peoptheader.DataDirectory[PE_DATADIR_TLS].vaddr:=tlssymbol.address;
+              peoptheader.DataDirectory[PE_DATADIR_TLS].size:=Sizeof(tlsdirectory);
+              if IsSharedLibrary then
+                begin
+                  { Here we should reset __FPC_tls_callbacks value to nil }
+                  callbackexesymbol:=texesymbol(ExeSymbolList.Find(
+                                        '__FPC_tls_callbacks'));
+                  if assigned (callbackexesymbol) then
+                    begin
+                      callbacksymbol:=callbackexesymbol.ObjSymbol;
+
+                    end;
+                end;
+
+           end;
+        end;
+
       begin
         result:=false;
         FCoffSyms:=TDynamicArray.Create(SymbolMaxGrow);
@@ -2245,6 +2347,7 @@ const pemagic : array[0..3] of byte = (
         textExeSec:=FindExeSection('.text');
         dataExeSec:=FindExeSection('.data');
         bssExeSec:=FindExeSection('.bss');
+        tlsExeSec:=FindExeSection('.tls');
         if not assigned(TextExeSec) or
            not assigned(DataExeSec) then
           internalerror(200602231);
@@ -2352,7 +2455,8 @@ const pemagic : array[0..3] of byte = (
             peoptheader.SizeOfHeapReserve:=$100000;
             peoptheader.SizeOfHeapCommit:=$1000;
             peoptheader.NumberOfRvaAndSizes:=PE_DATADIR_ENTRIES;
-            UpdateDataDir('.idata',PE_DATADIR_IDATA);
+            UpdateImports;
+            UpdateTlsDataDir;
             UpdateDataDir('.edata',PE_DATADIR_EDATA);
             UpdateDataDir('.rsrc',PE_DATADIR_RSRC);
             UpdateDataDir('.pdata',PE_DATADIR_PDATA);
@@ -2414,9 +2518,12 @@ const pemagic : array[0..3] of byte = (
         Result:=CompareStr(I1.Name,I2.Name);
       end;
 
-    procedure TCoffexeoutput.Order_ObjSectionList(ObjSectionList: TFPObjectList);
+    procedure TCoffexeoutput.Order_ObjSectionList(ObjSectionList: TFPObjectList;const aPattern:string);
       begin
-        if CurrExeSec.Name = '.idata' then
+        { Sort sections having '$' in the name, that's how PECOFF documentation
+          tells to handle them. However, look for '$' in the pattern, not in section
+          names, because the latter often get superfluous '$' due to mangling. }
+        if Pos('$',aPattern)>0 then
           ObjSectionList.Sort(@IdataObjSectionCompare);
       end;
 
@@ -2492,6 +2599,7 @@ const pemagic : array[0..3] of byte = (
           emptyint : longint;
         begin
           emptyint:=0;
+          { These are referenced from idata2, oso_keep is not necessary. }
           idata4objsection:=internalobjdata.createsection(sec_idata4, basedllname+'_z_');
           internalobjdata.SymbolDefine('__imp_names_end_'+basedllname,AB_LOCAL,AT_DATA);
           idata5objsection:=internalobjdata.createsection(sec_idata5, basedllname+'_z_');
@@ -2506,9 +2614,6 @@ const pemagic : array[0..3] of byte = (
           internalobjdata.writebytes(emptyint,sizeof(emptyint));
           if target_info.system=system_x86_64_win64 then
             internalobjdata.writebytes(emptyint,sizeof(emptyint));
-          { be sure that this will not be removed }
-          idata4objsection.SecOptions:=idata4objsection.SecOptions + [oso_keep];
-          idata5objsection.SecOptions:=idata5objsection.SecOptions + [oso_keep];
         end;
 
         function AddImport(const afuncname,amangledname:string; AOrdNr:longint;isvar:boolean):TObjSymbol;

+ 30 - 5
compiler/ogelf.pas

@@ -295,8 +295,8 @@ implementation
         end;
         telf64reloc=packed record
           address : qword;
-          info    : qword; { bit 0-7: type, 8-31: symbol }
-          addend  : qword;
+          info    : qword; { bit 0-31: type, 32-63: symbol }
+          addend  : int64; { signed! }
         end;
         telf64symbol=packed record
           st_name  : longint;
@@ -810,6 +810,8 @@ implementation
         relsym,
         reltyp   : longint;
         relocsect : TObjSection;
+        tmp: aint;
+        asize: longint;
       begin
         with elf32data do
          begin
@@ -861,7 +863,7 @@ implementation
                    begin
                      reltyp:=R_X86_64_PC32;
                      { length of the relocated location is handled here }
-                     rel.addend:=qword(-4);
+                     rel.addend:=-4;
                    end;
                  RELOC_ABSOLUTE :
                    reltyp:=R_X86_64_64;
@@ -871,19 +873,42 @@ implementation
                    begin
                      reltyp:=R_X86_64_GOTPCREL;
                      { length of the relocated location is handled here }
-                     rel.addend:=qword(-4);
+                     rel.addend:=-4;
                    end;
                  RELOC_PLT32 :
                    begin
                      reltyp:=R_X86_64_PLT32;
                      { length of the relocated location is handled here }
-                     rel.addend:=qword(-4);
+                     rel.addend:=-4;
                    end;
 {$endif x86_64}
                  else
                    internalerror(200602261);
                end;
 
+{ This handles ELF 'rela'-styled relocations, which are currently used only for x86_64,
+  but can be used other targets, too. }
+{$ifdef x86_64}
+               s.Data.Seek(objreloc.dataoffset);
+               if objreloc.typ=RELOC_ABSOLUTE then
+                 begin
+                   asize:=8;
+                   s.Data.Read(tmp,8);
+                   rel.addend:=rel.addend+tmp;
+                 end
+               else
+                 begin
+                   asize:=4;
+                   s.Data.Read(tmp,4);
+                   rel.addend:=rel.addend+longint(tmp);
+                 end;
+
+               { and zero the data member out }
+               tmp:=0;
+               s.Data.Seek(objreloc.dataoffset);
+               s.Data.Write(tmp,asize);
+{$endif}
+
                { Symbol }
                if assigned(objreloc.symbol) then
                  begin

+ 7 - 2
compiler/ognlm.pas

@@ -1198,7 +1198,12 @@ function SecOpts(SecOptions:TObjSectionOptions):string;
                     targetSectionName := '';
                     if objreloc.symbol <> nil then
                     begin
-                      // writeln ('  MemPos',objsec.MemPos,' dataOfs:',objreloc.dataoffset,' ',objsec.name,'   objreloc.symbol: ',objreloc.symbol.name,'  objreloc.symbol.objsection.name: ',objreloc.symbol.objsection.name,' ',objreloc.symbol.Typ,' ',objreloc.symbol.bind,' ',objreloc.Typ);
+                      // writeln ('  MemPos',objsec.MemPos,
+                      // ' dataOfs:',objreloc.dataoffset,' ',objsec.name,
+                      // '   objreloc.symbol: ',objreloc.symbol.name,
+                      // '  objreloc.symbol.objsection.name: ',objreloc.symbol.objsection.name,
+                      // ' ',objreloc.symbol.Typ,' ',objrel
+                      // oc.symbol.bind,' ',objreloc.Typ);
                       if objreloc.symbol.objsection.name[1] <> '.' then
                         targetSectionName := objreloc.symbol.name                       // specials like __bss_start__
                       else                                                              // dont use objsection.name because it begins with *
@@ -1313,7 +1318,7 @@ function SecOpts(SecOptions:TObjSectionOptions):string;
                    exit;
                  end;
                fileH := fileOpen (fn,fmOpenRead);
-               if fileH = -1 then
+               if fileH = THandle(-1) then
                  begin
                    comment(v_error,'can not open '+desc+' file '+fn);
                    exit;

+ 1 - 1
compiler/optcse.pas

@@ -173,7 +173,7 @@ unit optcse;
                     if plists(arg)^.equalto[i]<>pointer(-1) then
                       plists(arg)^.equalto[plists(arg)^.nodelist.count-1]:=plists(arg)^.equalto[i]
                     else
-                      plists(arg)^.equalto[plists(arg)^.nodelist.count-1]:=pointer(i);
+                      plists(arg)^.equalto[plists(arg)^.nodelist.count-1]:=pointer(ptrint(i));
                     plists(arg)^.refs[i]:=pointer(plists(arg)^.refs[i])+1;
                     break;
                   end;

+ 101 - 42
compiler/options.pas

@@ -1463,54 +1463,74 @@ begin
                   case More[j] of
                     'A':
                       begin
-                        if UnsetBool(More, j) then
-                          apptype:=app_native
+                        if target_info.system in systems_all_windows then
+                          begin
+                            if UnsetBool(More, j) then
+                              apptype:=app_cui
+                            else
+                              apptype:=app_native;
+                          end
                         else
-                          apptype:=app_cui;
+                          IllegalPara(opt);
                       end;
                     'b':
                       begin
-                        if (target_info.system in systems_darwin) then
+                        if target_info.system in systems_darwin then
                           begin
-                            if not UnsetBool(More, j) then
-                              apptype:=app_bundle
-                            else
+                            if UnsetBool(More, j) then
                               apptype:=app_cui
+                            else
+                              apptype:=app_bundle
                           end
                         else
                           IllegalPara(opt);
                       end;
                     'B':
                       begin
-                        {  -WB200000 means set trefered base address
-                          to $200000, but does not change relocsection boolean
-                          this way we can create both relocatble and
-                          non relocatable DLL at a specific base address PM }
-                        if (length(More)>j) then
+                        if target_info.system in systems_all_windows+systems_symbian then
                           begin
-                            val('$'+Copy(More,j+1,255),imagebase,code);
-                            if code<>0 then
-                              IllegalPara(opt);
-                            ImageBaseSetExplicity:=true;
+                            {  -WB200000 means set trefered base address
+                              to $200000, but does not change relocsection boolean
+                              this way we can create both relocatble and
+                              non relocatable DLL at a specific base address PM }
+                            if (length(More)>j) then
+                              begin
+                                val('$'+Copy(More,j+1,255),imagebase,code);
+                                if code<>0 then
+                                  IllegalPara(opt);
+                                ImageBaseSetExplicity:=true;
+                              end
+                            else
+                              begin
+                                RelocSection:=true;
+                                RelocSectionSetExplicitly:=true;
+                              end;
+                            break;
                           end
                         else
-                          begin
-                            RelocSection:=true;
-                            RelocSectionSetExplicitly:=true;
-                          end;
-                        break;
+                          IllegalPara(opt);
                       end;
                     'C':
                       begin
-                        if UnsetBool(More, j) then
-                          apptype:=app_gui
+                        if target_info.system in systems_all_windows+systems_os2+systems_macos then
+                          begin
+                            if UnsetBool(More, j) then
+                              apptype:=app_gui
+                            else
+                              apptype:=app_cui;
+                          end
                         else
-                          apptype:=app_cui;
+                          IllegalPara(opt);
                       end;
                     'D':
                       begin
-                        UseDeffileForExports:=not UnsetBool(More, j);
-                        UseDeffileForExportsSetExplicitly:=true;
+                        if target_info.system in systems_all_windows then
+                          begin
+                            UseDeffileForExports:=not UnsetBool(More, j);
+                            UseDeffileForExportsSetExplicitly:=true;
+                          end
+                        else
+                          IllegalPara(opt);
                       end;
                     'e':
                       begin
@@ -1525,22 +1545,37 @@ begin
                       end;
                     'F':
                       begin
-                        if UnsetBool(More, j) then
-                          apptype:=app_cui
+                        if target_info.system in systems_os2 then
+                          begin
+                            if UnsetBool(More, j) then
+                              apptype:=app_cui
+                            else
+                              apptype:=app_fs;
+                          end
                         else
-                          apptype:=app_fs;
+                          IllegalPara(opt);
                       end;
                     'G':
                       begin
-                        if UnsetBool(More, j) then
-                          apptype:=app_cui
+                        if target_info.system in systems_all_windows+systems_os2+systems_macos then
+                          begin
+                            if UnsetBool(More, j) then
+                              apptype:=app_cui
+                            else
+                              apptype:=app_gui;
+                          end
                         else
-                          apptype:=app_gui;
+                          IllegalPara(opt);
                       end;
                     'I':
                       begin
-                        GenerateImportSection:=not UnsetBool(More,j);
-                        GenerateImportSectionSetExplicitly:=true;
+                        if target_info.system in systems_all_windows then
+                          begin
+                            GenerateImportSection:=not UnsetBool(More,j);
+                            GenerateImportSectionSetExplicitly:=true;
+                          end
+                        else
+                          IllegalPara(opt);
                       end;
                     'i':
                       begin
@@ -1555,8 +1590,13 @@ begin
                       end;
                     'N':
                       begin
-                        RelocSection:=UnsetBool(More,j);
-                        RelocSectionSetExplicitly:=true;
+                        if target_info.system in systems_all_windows then
+                          begin
+                            RelocSection:=UnsetBool(More,j);
+                            RelocSectionSetExplicitly:=true;
+                          end
+                        else
+                          IllegalPara(opt);
                       end;
                     'p':
                       begin
@@ -1574,16 +1614,26 @@ begin
                       end;
                     'R':
                       begin
-                        { support -WR+ / -WR- as synonyms to -WR / -WN }
-                        RelocSection:=not UnsetBool(More,j);
-                        RelocSectionSetExplicitly:=true;
+                        if target_info.system in systems_all_windows then
+                          begin
+                            { support -WR+ / -WR- as synonyms to -WR / -WN }
+                            RelocSection:=not UnsetBool(More,j);
+                            RelocSectionSetExplicitly:=true;
+                          end
+                        else
+                          IllegalPara(opt);
                       end;
                     'T':
                       begin
-                        if UnsetBool(More, j) then
-                          apptype:=app_cui
+                        if target_info.system in systems_macos then
+                          begin
+                            if UnsetBool(More, j) then
+                              apptype:=app_cui
+                            else
+                              apptype:=app_tool;
+                          end
                         else
-                          apptype:=app_tool;
+                          IllegalPara(opt);
                       end;
                     'X':
                       begin
@@ -2398,6 +2448,9 @@ begin
     end;
   option.firstpass:=false;
 
+  { redefine target options so all defines are written even if no -Txxx is passed on the command line }
+  Option.TargetOptions(true);
+
 { target is set here, for wince the default app type is gui }
   if target_info.system in systems_wince then
     apptype:=app_gui;
@@ -2800,6 +2853,12 @@ if (target_info.system=system_arm_darwin) then
         def_system_macro('FPC_HAS_TYPE_EXTENDED');
 {$endif}
     end;
+    { Not ready yet }
+{$ifdef TEST_TLS_DIRECTORY}
+    if target_info.system in systems_windows then
+      def_system_macro('FPC_USE_TLS_DIRECTORY');
+{$endif TEST_TLS_DIRECTORY}
+
 
 {$ifdef ARM}
   { define FPC_DOUBLE_HILO_SWAPPED if needed to properly handle doubles in RTL }

+ 5 - 0
compiler/parser.pas

@@ -351,6 +351,7 @@ implementation
          current_exceptblock:=0;
          exceptblockcounter:=0;
          current_settings.maxfpuregisters:=-1;
+         current_settings.pmessage:=nil;
        { reset the unit or create a new program }
          { a unit compiled at command line must be inside the loaded_unit list }
          if (compile_level=1) then
@@ -481,6 +482,8 @@ implementation
                 current_procinfo:=oldcurrent_procinfo;
                 current_filepos:=oldcurrent_filepos;
                 current_settings:=old_settings;
+                { Restore all locally modified warning messages }
+                RestoreLocalVerbosity(current_settings.pmessage);
                 current_exceptblock:=0;
                 exceptblockcounter:=0;
               end;
@@ -518,6 +521,8 @@ implementation
            dec(compile_level);
            set_current_module(olddata^.old_current_module);
 
+           FreeLocalVerbosity(current_settings.pmessage);
+
            dispose(olddata);
          end;
     end;

+ 15 - 51
compiler/pdecsub.pas

@@ -82,7 +82,7 @@ implementation
        cutils,cclasses,
        { global }
        globtype,globals,verbose,constexp,
-       systems,
+       systems,fpccrc,
        cpuinfo,
        { symtable }
        symbase,symtable,defutil,defcmp,paramgr,cpupara,
@@ -184,7 +184,7 @@ implementation
              paranr:=paranr_result_leftright
            else
 {$elseif defined(x86) or defined(arm)}
-           if (target_info.system in systems_all_windows) and
+           if (tf_safecall_exceptions in target_info.flags) and
               (pd.proccalloption = pocall_safecall)  then
              paranr:=paranr_result_leftright
            else
@@ -1455,7 +1455,7 @@ implementation
                        end;
                      if (optoken in [_EQ,_NE,_GT,_LT,_GTE,_LTE,_OP_IN]) and
                         ((pd.returndef.typ<>orddef) or
-                         (torddef(pd.returndef).ordtype<>pasbool)) then
+                         (torddef(pd.returndef).ordtype<>pasbool8)) then
                         Message(parser_e_comparative_operator_return_boolean);
                      if (optoken in [_ASSIGNMENT,_OP_EXPLICIT]) and
                         equal_defs(pd.returndef,tparavarsym(pd.parast.SymList[0]).vardef) and
@@ -1613,6 +1613,7 @@ begin
   if pd.parast.symtablelevel>normal_function_level then
     Message(parser_e_dont_nest_interrupt);
 
+{$ifdef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
   if target_info.system in systems_interrupt_table then
     begin
       if token<>_SEMICOLON then
@@ -1622,6 +1623,7 @@ begin
           Tprocdef(pd).interruptvector:=v.uvalue;
         end;
     end;
+{$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
 end;
 
 procedure pd_abstract(pd:tabstractprocdef);
@@ -2705,14 +2707,8 @@ const
 
 
     function proc_get_importname(pd:tprocdef):string;
-
-       function maybe_cprefix(const s:string):string;
-         begin
-           if not(pd.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
-             result:=s
-           else
-             result:=target_info.Cprefix+s;
-         end;
+      var
+        dllname, importname : string;
 
       begin
         result:='';
@@ -2722,36 +2718,15 @@ const
         if assigned(pd.import_name) or (pd.import_nr<>0) then
           begin
             if assigned(pd.import_dll) then
-              begin
-                { If we are not using direct dll linking under win32 then imports
-                  need to use the normal name since two functions can refer to the
-                  same DLL function. This is also needed for compatability
-                  with Delphi and TP7 }
-(*
-                case target_info.system of
-                  system_i386_emx,
-                  system_i386_os2 :
-                    begin
-                      { keep normal mangledname }
-                      if not (Assigned (PD.Import_Name)) then
-                       Result := PD.MangledName;
-                    end;
-                  else
-*)
-                if assigned(pd.import_name) then
-                  begin
-                    if target_info.system in (systems_all_windows + systems_nativent +
-                                       [system_i386_emx, system_i386_os2]) then
-                   { cprefix is not used in DLL imports under Windows or OS/2 }
-                      result:=pd.import_name^
-                    else
-                      result:=maybe_cprefix(pd.import_name^);
-                  end
-                else
-                  result:=ExtractFileName(pd.import_dll^)+'_index_'+tostr(pd.import_nr);
-              end
+              dllname:=pd.import_dll^
+            else
+              dllname:='';
+            if assigned(pd.import_name) then
+              importname:=pd.import_name^
             else
-              result:=maybe_cprefix(pd.import_name^);
+              importname:='';
+            proc_get_importname:=make_dllmangledname(dllname,
+              importname,pd.import_nr,pd.proccalloption);
           end
         else
           begin
@@ -2798,17 +2773,6 @@ const
                     s:=proc_get_importname(pd);
                     if s<>'' then
                       begin
-                        { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. }
-                        { This allows to import VC++ mangled names from DLLs. }
-                        { Do not perform replacement, if external symbol is not imported from DLL. }
-                        if (target_info.system in systems_all_windows) and (pd.import_dll<>nil) then
-                          begin
-                            Replace(s,'?','__q$$');
-{$ifdef arm}
-                            { @ symbol is not allowed in ARM assembler only }
-                            Replace(s,'@','__a$$');
-{$endif arm}
-                          end;
                         pd.setmangledname(s);
                       end;
                   end;

+ 35 - 10
compiler/pdecvar.pas

@@ -41,6 +41,8 @@ interface
 
     procedure read_public_and_external(vs: tabstractvarsym);
 
+    procedure try_consume_sectiondirective(var asection: ansistring);
+
 implementation
 
     uses
@@ -674,7 +676,7 @@ implementation
                                    storedprocdef:=tprocvardef.create(normal_function_level);
                                    include(storedprocdef.procoptions,po_methodpointer);
                                    { Return type must be boolean }
-                                   storedprocdef.returndef:=booltype;
+                                   storedprocdef.returndef:=pasbool8type;
                                    { Add index parameter if needed }
                                    if ppo_indexed in p.propoptions then
                                      begin
@@ -925,8 +927,8 @@ implementation
       is_external_var,
       is_weak_external,
       is_public_var  : boolean;
-      dll_name,
-      C_name      : string;
+      dll_name,section_name,
+      C_name,mangledname      : string;
     begin
       { only allowed for one var }
       { only allow external and public on global symbols }
@@ -940,6 +942,7 @@ implementation
       is_cdecl:=false;
       is_external_var:=false;
       is_public_var:=false;
+      section_name := '';
       C_name:=vs.realname;
 
       { macpas specific handling due to some switches}
@@ -992,6 +995,10 @@ implementation
             is_public_var:=true;
           if try_to_consume(_NAME) then
             C_name:=get_stringconst;
+          if (target_info.system in systems_allow_section_no_semicolon) and
+             (vs.typ=staticvarsym) and
+             try_to_consume (_SECTION) then
+            section_name:=get_stringconst;
           consume(_SEMICOLON);
         end;
 
@@ -1000,6 +1007,14 @@ implementation
          (target_info.system in systems_all_windows) then
         include(vs.varoptions,vo_is_dll_var);
 
+      { This can only happen if vs.typ=staticvarsym }
+      if section_name<>'' then
+        begin
+          tstaticvarsym(vs).section:=section_name;
+          include(vs.varoptions,vo_has_section);
+        end;
+
+
       { Add C _ prefix }
       if is_cdecl or
          (
@@ -1016,6 +1031,7 @@ implementation
           inc(vs.refs);
         end;
 
+      mangledname:=C_name;
       { now we can insert it in the import lib if its a dll, or
         add it to the externals }
       if is_external_var then
@@ -1031,14 +1047,20 @@ implementation
             end;
           vs.varregable := vr_none;
           if is_dll then
-            current_module.AddExternalImport(dll_name,C_Name,0,true,false)
+            begin
+              if target_info.system in (systems_all_windows + systems_nativent +
+                                       [system_i386_emx, system_i386_os2]) then
+                mangledname:=make_dllmangledname(dll_name,C_name,0,pocall_none);
+
+              current_module.AddExternalImport(dll_name,C_Name,mangledname,0,true,false);
+            end
           else
             if tf_has_dllscanner in target_info.flags then
               current_module.dllscannerinputlist.Add(vs.mangledname,vs);
         end;
 
       { Set the assembler name }
-      tstaticvarsym(vs).set_mangledname(C_Name);
+      tstaticvarsym(vs).set_mangledname(mangledname);
     end;
 
 
@@ -1265,7 +1287,7 @@ implementation
          hintsymoptions  : tsymoptions;
          deprecatedmsg   : pshortstring;
          old_block_type  : tblock_type;
-         section : ansistring;
+         sectionname : ansistring;
       begin
          old_block_type:=block_type;
          block_type:=bt_var;
@@ -1408,10 +1430,12 @@ implementation
                read_public_and_external_sc(sc);
 
              { try to parse a section directive }
-             if (target_info.system in systems_embedded) and (idtoken=_SECTION) then
+             if (target_info.system in systems_allow_section) and
+                (symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) and
+                (idtoken=_SECTION) then
                begin
-                 try_consume_sectiondirective(section);
-                 if section<>'' then
+                 try_consume_sectiondirective(sectionname);
+                 if sectionname<>'' then
                    begin
                      for i:=0 to sc.count-1 do
                        begin
@@ -1420,7 +1444,8 @@ implementation
                            Message(parser_e_externals_no_section);
                          if vs.typ<>staticvarsym then
                            Message(parser_e_section_no_locals);
-                         tstaticvarsym(vs).section:=section;
+                         tstaticvarsym(vs).section:=sectionname;
+                         include(vs.varoptions, vo_has_section);
                        end;
                    end;
                end;

+ 2 - 2
compiler/pexpr.pas

@@ -2766,13 +2766,13 @@ implementation
              _TRUE :
                begin
                  consume(_TRUE);
-                 p1:=cordconstnode.create(1,booltype,false);
+                 p1:=cordconstnode.create(1,pasbool8type,false);
                end;
 
              _FALSE :
                begin
                  consume(_FALSE);
-                 p1:=cordconstnode.create(0,booltype,false);
+                 p1:=cordconstnode.create(0,pasbool8type,false);
                end;
 
              _NIL :

+ 3 - 7
compiler/pmodules.pas

@@ -1357,9 +1357,6 @@ implementation
          gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.globalsymtable,false);
          gen_intf_wrappers(current_asmdata.asmlists[al_procedures],current_module.localsymtable,false);
 
-         { generate pic helpers to load eip if necessary }
-         gen_pic_helpers(current_asmdata.asmlists[al_procedures]);
-
          { generate rtti/init tables }
          write_persistent_type_info(current_module.globalsymtable);
          write_persistent_type_info(current_module.localsymtable);
@@ -1752,7 +1749,7 @@ implementation
         hp:=texported_item(current_module._exports.first);
         while assigned(hp) do
           begin
-            current_module.AddExternalImport(current_module.realmodulename^,hp.name^,hp.index,hp.is_var,false);
+            current_module.AddExternalImport(current_module.realmodulename^,hp.name^,hp.name^,hp.index,hp.is_var,false);
             hp:=texported_item(hp.next);
           end;
       end;
@@ -2313,9 +2310,6 @@ implementation
 
          InsertThreadvars;
 
-         { generate pic helpers to load eip if necessary }
-         gen_pic_helpers(current_asmdata.asmlists[al_procedures]);
-
          { generate rtti/init tables }
          write_persistent_type_info(current_module.localsymtable);
 
@@ -2353,8 +2347,10 @@ implementation
          InsertWideInitsTablesTable;
          InsertMemorySizes;
 
+{$ifdef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
          if target_info.system in systems_interrupt_table then
            InsertInterruptTable;
+{$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
 
          { Insert symbol to resource info }
          InsertResourceInfo(resources_used);

+ 7 - 68
compiler/powerpc/agppcmpw.pas

@@ -479,25 +479,6 @@ interface
       t[3]:= b;
     end;
 
-   function fixline(s:string):string;
-   {
-     return s with all leading and ending spaces and tabs removed
-   }
-     var
-       i,j,k : longint;
-     begin
-       i:=length(s);
-       while (i>0) and (s[i] in [#9,' ']) do
-        dec(i);
-       j:=1;
-       while (j<i) and (s[j] in [#9,' ']) do
-        inc(j);
-       for k:=j to i do
-        if s[k] in [#0..#31,#127..#255] then
-         s[k]:='.';
-       fixline:=Copy(s,j,i-j+1);
-     end;
-
     Function PadTabs(const p:string;addch:char):string;
     var
       s : string;
@@ -712,7 +693,6 @@ interface
     var
       s        : string;
       hp       : tai;
-      hp1      : tailineinfo;
       counter,
       lines,
       InlineLevel : longint;
@@ -735,54 +715,13 @@ interface
       hp:=tai(p.first);
       while assigned(hp) do
        begin
-         if not(hp.typ in SkipLineInfo) and
-            not DoNotSplitLine then
-           begin
-             hp1 := hp as tailineinfo;
-
-             if do_line then
-              begin
-           { load infile }
-             if lastfileinfo.fileindex<>hp1.fileinfo.fileindex then
-              begin
-                infile:=current_module.sourcefiles.get_file(hp1.fileinfo.fileindex);
-                if assigned(infile) then
-                 begin
-                   { open only if needed !! }
-                   if (cs_asm_source in current_settings.globalswitches) then
-                    infile.open;
-                 end;
-                { avoid unnecessary reopens of the same file !! }
-                lastfileinfo.fileindex:=hp1.fileinfo.fileindex;
-                { be sure to change line !! }
-                lastfileinfo.line:=-1;
-              end;
-           { write source }
-             if (cs_asm_source in current_settings.globalswitches) and
-                assigned(infile) then
-              begin
-                if (infile<>lastinfile) then
-                  begin
-                    AsmWriteLn(target_asm.comment+'['+infile.name^+']');
-                    if assigned(lastinfile) then
-                      lastinfile.close;
-                  end;
-                if (hp1.fileinfo.line<>lastfileinfo.line) and
-                   ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
-                  begin
-                    if (hp1.fileinfo.line<>0) and
-                       ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
-                      AsmWriteLn(target_asm.comment+'['+tostr(hp1.fileinfo.line)+'] '+
-                        fixline(infile.GetLineStr(hp1.fileinfo.line)));
-                    { set it to a negative value !
-                    to make that is has been read already !! PM }
-                    if (infile.linebuf^[hp1.fileinfo.line]>=0) then
-                      infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
-                  end;
-              end;
-             lastfileinfo:=hp1.fileinfo;
-             lastinfile:=infile;
-           end;
+         prefetch(pointer(hp.next)^);
+         if not(hp.typ in SkipLineInfo) then
+          begin
+            current_filepos:=tailineinfo(hp).fileinfo;
+            { no line info for inlined code }
+            if do_line and (inlinelevel=0) and not DoNotSplitLine then
+              WriteSourceLine(hp as tailineinfo);
           end;
 
          DoNotSplitLine:=false;

+ 1 - 1
compiler/powerpc/cgcpu.pas

@@ -275,7 +275,7 @@ const
           { TODO: optimize/take into consideration fromsize/tosize. Will }
           { probably only matter for OS_S8 loads though                  }
           if not(fromsize in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then
-            internalerror(2002090902);
+            internalerror(2002090903);
           ref2 := ref;
           fixref(list,ref2);
           { the caller is expected to have adjusted the reference already }

+ 1 - 1
compiler/powerpc64/rappcgas.pas

@@ -687,7 +687,7 @@ begin
     dec(ord(hs[0]));
     actcondition.dirhint := DH_Plus;
   end;
-  actopcode := tasmop(ptrint(iasmops.Find(hs)));
+  actopcode := tasmop(ptruint(iasmops.Find(hs)));
   if actopcode <> A_NONE then
   begin
     if actcondition.dirhint <> DH_None then

+ 3 - 2
compiler/ppcgen/cgppc.pas

@@ -440,7 +440,7 @@ unit cgppc;
       op: TAsmOp;
     begin
       if not (fromsize in [OS_8..OS_INT,OS_S8..OS_SINT]) then
-        internalerror(2002090903);
+        internalerror(2002090904);
       if not (tosize in [OS_8..OS_INT,OS_S8..OS_SINT]) then
         internalerror(2002090905);
 
@@ -580,7 +580,8 @@ unit cgppc;
       current_asmdata.getjumplabel(hl);
       if not ((def.typ=pointerdef) or
              ((def.typ=orddef) and
-              (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,pasbool]))) then
+              (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,
+                                        pasbool8,pasbool16,pasbool32,pasbool64]))) then
         begin
           if (current_settings.optimizecputype >= cpu_ppc970) or
              (current_settings.cputype >= cpu_ppc970) then

+ 4 - 4
compiler/ppcgen/ngppcadd.pas

@@ -177,12 +177,12 @@ implementation
         firstcomplex(self);
 
         cmpop:=false;
-        if (torddef(left.resultdef).ordtype in [pasbool,bool8bit]) or
-           (torddef(right.resultdef).ordtype in [pasbool,bool8bit]) then
+        if (torddef(left.resultdef).ordtype in [pasbool8,bool8bit]) or
+           (torddef(right.resultdef).ordtype in [pasbool8,bool8bit]) then
          cgsize:=OS_8
         else
-          if (torddef(left.resultdef).ordtype=bool16bit) or
-             (torddef(right.resultdef).ordtype=bool16bit) then
+          if (torddef(left.resultdef).ordtype in [pasbool16,bool16bit]) or
+             (torddef(right.resultdef).ordtype in [pasbool16,bool16bit]) then
            cgsize:=OS_16
         else
            cgsize:=OS_32;

+ 179 - 35
compiler/ppu.pas

@@ -230,6 +230,9 @@ type
       used by this unit. Reason: see mantis #13840 }
     indirect_crc     : cardinal;
     error,
+{$ifdef generic_cpu}
+    has_more,
+{$endif not generic_cpu}
     do_crc,
     do_interface_crc,
     do_indirect_crc  : boolean;
@@ -250,6 +253,7 @@ type
     function  readentry:byte;
     function  EndOfEntry:boolean;
     function  entrysize:longint;
+    function  entryleft:longint;
     procedure getdatabuf(var b;len:integer;var res:integer);
     procedure getdata(var b;len:integer);
     function  getbyte:byte;
@@ -262,6 +266,7 @@ type
     function getasizeint:asizeint;
     function getaword:aword;
     function  getreal:ppureal;
+    function  getrealsize(sizeofreal : longint):ppureal;
     function  getstring:string;
     function  getansistring:ansistring;
     procedure getnormalset(var b);
@@ -301,6 +306,47 @@ implementation
     fpccrc,
     cutils;
 
+{$ifdef generic_cpu}
+{ We need to use the correct size of aint and pint for
+  the target CPU }
+const
+  CpuAddrBitSize : array[tsystemcpu] of longint =
+    (
+    {  0 } 32 {'none'},
+    {  1 } 32 {'i386'},
+    {  2 } 32 {'m68k'},
+    {  3 } 32 {'alpha'},
+    {  4 } 32 {'powerpc'},
+    {  5 } 32 {'sparc'},
+    {  6 } 32 {'vis'},
+    {  7 } 64 {'ia64'},
+    {  8 } 64 {'x86_64'},
+    {  9 } 32 {'mips'},
+    { 10 } 32 {'arm'},
+    { 11 } 64 {'powerpc64'},
+    { 12 } 16 {'avr'},
+    { 13 } 32 {'mipsel'}
+    );
+  CpuAluBitSize : array[tsystemcpu] of longint =
+    (
+    {  0 } 32 {'none'},
+    {  1 } 32 {'i386'},
+    {  2 } 32 {'m68k'},
+    {  3 } 32 {'alpha'},
+    {  4 } 32 {'powerpc'},
+    {  5 } 32 {'sparc'},
+    {  6 } 32 {'vis'},
+    {  7 } 64 {'ia64'},
+    {  8 } 64 {'x86_64'},
+    {  9 } 32 {'mips'},
+    { 10 } 32 {'arm'},
+    { 11 } 64 {'powerpc64'},
+    { 12 }  8 {'avr'},
+    { 13 } 32 {'mipsel'}
+    );
+{$endif generic_cpu}
+
+
 
 function swapendian_ppureal(d:ppureal):ppureal;
 
@@ -530,12 +576,20 @@ end;
 function tppufile.readentry:byte;
 begin
   if entryidx<entry.size then
-   skipdata(entry.size-entryidx);
+    begin
+{$ifdef generic_cpu}
+     has_more:=true;
+{$endif not generic_cpu}
+     skipdata(entry.size-entryidx);
+    end;
   readdata(entry,sizeof(tppuentry));
   if change_endian then
     entry.size:=swapendian(entry.size);
   entrystart:=bufstart+bufidx;
   entryidx:=0;
+{$ifdef generic_cpu}
+  has_more:=false;
+{$endif not generic_cpu}
   if not(entry.id in [mainentryid,subentryid]) then
    begin
      readentry:=iberror;
@@ -548,7 +602,11 @@ end;
 
 function tppufile.endofentry:boolean;
 begin
+{$ifdef generic_cpu}
+  endofentry:=(entryidx=entry.size);
+{$else not generic_cpu}
   endofentry:=(entryidx>=entry.size);
+{$endif not generic_cpu}
 end;
 
 
@@ -557,6 +615,11 @@ begin
   entrysize:=entry.size;
 end;
 
+function tppufile.entryleft:longint;
+begin
+  entryleft:=entry.size-entryidx;
+end;
+
 
 procedure tppufile.getdatabuf(var b;len:integer;var res:integer);
 begin
@@ -707,68 +770,154 @@ end;
 
 function tppufile.getaint:aint;
 begin
+{$ifdef generic_cpu}
+  if CpuAluBitSize[tsystemcpu(header.cpu)]=64 then
+    result:=getint64
+  else if CpuAluBitSize[tsystemcpu(header.cpu)]=32 then
+    result:=getlongint
+  else if CpuAluBitSize[tsystemcpu(header.cpu)]=16 then
+    result:=smallint(getword)
+  else if CpuAluBitSize[tsystemcpu(header.cpu)]=8 then
+    result:=shortint(getbyte)
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
+{$else not generic_cpu}
 {$ifdef cpu64bitalu}
   result:=getint64;
 {$else cpu64bitalu}
   result:=getlongint;
 {$endif cpu64bitalu}
+{$endif not generic_cpu}
 end;
 
 
 function tppufile.getasizeint:asizeint;
 begin
+{$ifdef generic_cpu}
+  if CpuAddrBitSize[tsystemcpu(header.cpu)]=64 then
+    result:=getint64
+  else if CpuAddrBitSize[tsystemcpu(header.cpu)]=32 then
+    result:=getlongint
+  else if CpuAddrBitSize[tsystemcpu(header.cpu)]=16 then
+    result:=smallint(getword)
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
+{$else not generic_cpu}
 {$ifdef cpu64bitaddr}
   result:=getint64;
 {$else cpu64bitaddr}
   result:=getlongint;
 {$endif cpu32bitaddr}
+{$endif not generic_cpu}
 end;
 
 
 function tppufile.getaword:aword;
 begin
+{$ifdef generic_cpu}
+  if CpuAluBitSize[tsystemcpu(header.cpu)]=64 then
+    result:=getqword
+  else if CpuAluBitSize[tsystemcpu(header.cpu)]=32 then
+    result:=getdword
+  else if CpuAluBitSize[tsystemcpu(header.cpu)]=16 then
+    result:=getword
+  else if CpuAluBitSize[tsystemcpu(header.cpu)]=8 then
+    result:=getbyte
+  else
+    begin
+      error:=true;
+      result:=0;
+    end;
+{$else not generic_cpu}
 {$ifdef cpu64bitalu}
   result:=getqword;
 {$else cpu64bitalu}
   result:=getdword;
 {$endif cpu64bitalu}
+{$endif not generic_cpu}
 end;
 
-
-function tppufile.getreal:ppureal;
+function  tppufile.getrealsize(sizeofreal : longint):ppureal;
 var
-  d : ppureal;
-  hd : double;
+  e : ppureal;
+  d : double;
+  s : single;
 begin
-  if target_info.system=system_x86_64_win64 then
+  if sizeofreal=sizeof(e) then
     begin
-      if entryidx+sizeof(hd)>entry.size then
+      if entryidx+sizeof(e)>entry.size then
        begin
          error:=true;
-         getreal:=0;
+         result:=0;
          exit;
        end;
-      readdata(hd,sizeof(hd));
+      readdata(e,sizeof(e));
       if change_endian then
-        getreal:=swapendian(qword(hd))
+        result:=swapendian_ppureal(e)
       else
-        getreal:=hd;
-      inc(entryidx,sizeof(hd));
-    end
-  else
+        result:=e;
+      inc(entryidx,sizeof(e));
+      result:=e;
+      exit;
+    end;
+  if sizeofreal=sizeof(d) then
     begin
-      if entryidx+sizeof(ppureal)>entry.size then
+      if entryidx+sizeof(d)>entry.size then
        begin
          error:=true;
-         getreal:=0;
+         result:=0;
          exit;
        end;
-      readdata(d,sizeof(ppureal));
+      readdata(d,sizeof(d));
       if change_endian then
-        getreal:=swapendian_ppureal(d)
+        result:=swapendian(pqword(@d)^)
       else
-        getreal:=d;
-      inc(entryidx,sizeof(ppureal));
+        result:=d;
+      inc(entryidx,sizeof(d));
+      result:=d;
+      exit;
+    end;
+  if sizeofreal=sizeof(s) then
+    begin
+      if entryidx+sizeof(s)>entry.size then
+       begin
+         error:=true;
+         result:=0;
+         exit;
+       end;
+      readdata(s,sizeof(s));
+      if change_endian then
+        result:=swapendian(pdword(@s)^)
+      else
+        result:=s;
+      inc(entryidx,sizeof(s));
+      result:=s;
+      exit;
+    end;
+  error:=true;
+  result:=0.0;
+end;
+
+function tppufile.getreal:ppureal;
+var
+  d : ppureal;
+  hd : double;
+begin
+  if target_info.system=system_x86_64_win64 then
+    begin
+      hd:=getrealsize(sizeof(hd));
+      getreal:=hd;
+    end
+  else
+    begin
+      d:=getrealsize(sizeof(d));
+      getreal:=d;
     end;
 end;
 
@@ -1181,6 +1330,7 @@ procedure tppufile.tempclose;
      begin
        closepos:=f.Position;
        f.Free;
+       f:=nil;
        closed:=true;
        tempclosed:=true;
      end;
@@ -1188,25 +1338,19 @@ procedure tppufile.tempclose;
 
 
 function tppufile.tempopen:boolean;
-  //var
-  //  ofm : byte;
   begin
     tempopen:=false;
     if not closed or not tempclosed then
      exit;
-    // MG: not sure, if this is correct
-
-    f.Position:=0;
-    (*
-    ofm:=filemode;
-    filemode:=0;
-    {$I-}
-     reset(f,1);
-    {$I+}
-    filemode:=ofm;
-    if ioresult<>0 then
-     exit;
-    *)
+   { MG: not sure, if this is correct
+     f.position:=0;
+       No, f was freed in tempclose above, we need to
+       recreate it.  PM 2011/06/06 }
+    try
+      f:=CFileStreamClass.Create(fname,fmOpenRead);
+    except
+      exit;
+    end;
     closed:=false;
     tempclosed:=false;
 

+ 45 - 0
compiler/pstatmnt.pas

@@ -516,19 +516,36 @@ implementation
          hp,
          refnode  : tnode;
          hdef : tdef;
+         extendeddef : tabstractrecorddef;
+         helperdef : tobjectdef;
          hasimplicitderef : boolean;
          withsymtablelist : TFPObjectList;
 
          procedure pushobjchild(withdef,obj:tobjectdef);
+         var
+           parenthelperdef : tobjectdef;
          begin
            if not assigned(obj) then
              exit;
            pushobjchild(withdef,obj.childof);
+           { we need to look for helpers that were defined for the parent
+             class as well }
+           search_last_objectpascal_helper(obj,current_structdef,parenthelperdef);
+           { push the symtables of the helper's parents in reverse order }
+           if assigned(parenthelperdef) then
+             pushobjchild(withdef,parenthelperdef.childof);
            { keep the original tobjectdef as owner, because that is used for
              visibility of the symtable }
            st:=twithsymtable.create(withdef,obj.symtable.SymList,refnode.getcopy);
            symtablestack.push(st);
            withsymtablelist.add(st);
+           { push the symtable of the helper }
+           if assigned(parenthelperdef) then
+             begin
+               st:=twithsymtable.create(withdef,parenthelperdef.symtable.SymList,refnode.getcopy);
+               symtablestack.push(st);
+               withsymtablelist.add(st);
+             end;
          end;
 
 
@@ -625,12 +642,25 @@ implementation
                 typecheckpass(refnode);
               end;
 
+            { do we have a helper for this type? }
+            if p.resultdef.typ=classrefdef then
+              extendeddef:=tobjectdef(tclassrefdef(p.resultdef).pointeddef)
+            else
+              extendeddef:=tabstractrecorddef(p.resultdef);
+            search_last_objectpascal_helper(extendeddef,current_structdef,helperdef);
+            { Note: the symtable of the helper is pushed after the following
+                    "case", the symtables of the helper's parents are passed in
+                    the "case" branches }
+
             withsymtablelist:=TFPObjectList.create(true);
             case p.resultdef.typ of
               objectdef :
                 begin
                    { push symtables of all parents in reverse order }
                    pushobjchild(tobjectdef(p.resultdef),tobjectdef(p.resultdef).childof);
+                   { push symtables of all parents of the helper in reverse order }
+                   if assigned(helperdef) then
+                     pushobjchild(helperdef,helperdef.childof);
                    { push object symtable }
                    st:=twithsymtable.Create(tobjectdef(p.resultdef),tobjectdef(p.resultdef).symtable.SymList,refnode);
                    symtablestack.push(st);
@@ -640,6 +670,9 @@ implementation
                 begin
                    { push symtables of all parents in reverse order }
                    pushobjchild(tobjectdef(tclassrefdef(p.resultdef).pointeddef),tobjectdef(tclassrefdef(p.resultdef).pointeddef).childof);
+                   { push symtables of all parents of the helper in reverse order }
+                   if assigned(helperdef) then
+                     pushobjchild(helperdef,helperdef.childof);
                    { push object symtable }
                    st:=twithsymtable.Create(tobjectdef(tclassrefdef(p.resultdef).pointeddef),tobjectdef(tclassrefdef(p.resultdef).pointeddef).symtable.SymList,refnode);
                    symtablestack.push(st);
@@ -647,6 +680,10 @@ implementation
                 end;
               recorddef :
                 begin
+                   { push symtables of all parents of the helper in reverse order }
+                   if assigned(helperdef) then
+                     pushobjchild(helperdef,helperdef.childof);
+                   { push record symtable }
                    st:=twithsymtable.create(trecorddef(p.resultdef),trecorddef(p.resultdef).symtable.SymList,refnode);
                    symtablestack.push(st);
                    withsymtablelist.add(st);
@@ -655,6 +692,14 @@ implementation
                 internalerror(200601271);
             end;
 
+            { push helper symtable }
+            if assigned(helperdef) then
+              begin
+                st:=twithsymtable.Create(helperdef,helperdef.symtable.SymList,refnode.getcopy);
+                symtablestack.push(st);
+                withsymtablelist.add(st);
+              end;
+
             if try_to_consume(_COMMA) then
               p:=_with_statement()
             else

+ 20 - 2
compiler/psub.pas

@@ -162,6 +162,8 @@ implementation
 
 
     function block(islibrary : boolean) : tnode;
+      var
+        oldfilepos: tfileposinfo;
       begin
          { parse const,types and vars }
          read_declarations(islibrary);
@@ -240,7 +242,14 @@ implementation
             begin
                block:=statement_block(_BEGIN);
                if current_procinfo.procdef.localst.symtabletype=localsymtable then
-                 current_procinfo.procdef.localst.SymList.ForEachCall(@initializevars,block);
+                 begin
+                   { initialization of local variables with their initial
+                     values: part of function entry }
+                   oldfilepos:=current_filepos;
+                   current_filepos:=current_procinfo.entrypos;
+                   current_procinfo.procdef.localst.SymList.ForEachCall(@initializevars,block);
+                   current_filepos:=oldfilepos;
+                 end;
             end;
       end;
 
@@ -1768,7 +1777,16 @@ implementation
 
                  { Import DLL specified? }
                  if assigned(pd.import_dll) then
-                   current_module.AddExternalImport(pd.import_dll^,proc_get_importname(pd),pd.import_nr,false,pd.import_name=nil)
+                   begin
+                     if assigned (pd.import_name) then
+                       current_module.AddExternalImport(pd.import_dll^,
+                         pd.import_name^,proc_get_importname(pd),
+                         pd.import_nr,false,false)
+                     else
+                       current_module.AddExternalImport(pd.import_dll^,
+                         proc_get_importname(pd),proc_get_importname(pd),
+                         pd.import_nr,false,true);
+                   end
                  else
                    begin
                      { add import name to external list for DLL scanning }

+ 24 - 12
compiler/psystem.pas

@@ -154,7 +154,10 @@ implementation
         s32inttype:=torddef.create(s32bit,int64(low(longint)),int64(high(longint)));
         u64inttype:=torddef.create(u64bit,low(qword),high(qword));
         s64inttype:=torddef.create(s64bit,low(int64),high(int64));
-        booltype:=torddef.create(pasbool,0,1);
+        pasbool8type:=torddef.create(pasbool8,0,1);
+        pasbool16type:=torddef.create(pasbool16,0,1);
+        pasbool32type:=torddef.create(pasbool32,0,1);
+        pasbool64type:=torddef.create(pasbool64,0,1);
         bool8type:=torddef.create(bool8bit,low(int64),high(int64));
         bool16type:=torddef.create(bool16bit,low(int64),high(int64));
         bool32type:=torddef.create(bool32bit,low(int64),high(int64));
@@ -293,7 +296,10 @@ implementation
         addtype('UnicodeString',cunicodestringtype);
 
         addtype('OpenString',openshortstringtype);
-        addtype('Boolean',booltype);
+        addtype('Boolean',pasbool8type);
+        addtype('Boolean16',pasbool16type);
+        addtype('Boolean32',pasbool32type);
+        addtype('Boolean64',pasbool64type);
         addtype('ByteBool',bool8type);
         addtype('WordBool',bool16type);
         addtype('LongBool',bool32type);
@@ -333,11 +339,14 @@ implementation
         addtype('$widestring',cwidestringtype);
         addtype('$unicodestring',cunicodestringtype);
         addtype('$openshortstring',openshortstringtype);
-        addtype('$boolean',booltype);
-        addtype('$boolean8',bool8type);
-        addtype('$boolean16',bool16type);
-        addtype('$boolean32',bool32type);
-        addtype('$boolean64',bool64type);
+        addtype('$boolean',pasbool8type);
+        addtype('$boolean16',pasbool16type);
+        addtype('$boolean32',pasbool32type);
+        addtype('$boolean64',pasbool64type);
+        addtype('$bytebool',bool8type);
+        addtype('$wordbool',bool16type);
+        addtype('$longbool',bool32type);
+        addtype('$qwordbool',bool64type);
         addtype('$void_pointer',voidpointertype);
         addtype('$char_pointer',charpointertype);
         addtype('$widechar_pointer',widecharpointertype);
@@ -438,11 +447,14 @@ implementation
             loadtype('sc80real',sc80floattype);
           end;
         loadtype('s64currency',s64currencytype);
-        loadtype('boolean',booltype);
-        loadtype('boolean8',bool8type);
-        loadtype('boolean16',bool16type);
-        loadtype('boolean32',bool32type);
-        loadtype('boolean64',bool64type);
+        loadtype('boolean',pasbool8type);
+        loadtype('boolean16',pasbool16type);
+        loadtype('boolean32',pasbool32type);
+        loadtype('boolean64',pasbool64type);
+        loadtype('bytebool',bool8type);
+        loadtype('wordbool',bool16type);
+        loadtype('longbool',bool32type);
+        loadtype('qwordbool',bool64type);
         loadtype('void_pointer',voidpointertype);
         loadtype('char_pointer',charpointertype);
         loadtype('widechar_pointer',widecharpointertype);

+ 26 - 2
compiler/ptconst.pas

@@ -196,7 +196,7 @@ implementation
            if is_cbool(def) then
              inserttypeconv(n,def);
            case def.ordtype of
-              pasbool,
+              pasbool8,
               bool8bit :
                 begin
                    if is_constboolnode(n) then
@@ -204,6 +204,7 @@ implementation
                    else
                      do_error;
                 end;
+              pasbool16,
               bool16bit :
                 begin
                    if is_constboolnode(n) then
@@ -211,6 +212,7 @@ implementation
                    else
                      do_error;
                 end;
+              pasbool32,
               bool32bit :
                 begin
                    if is_constboolnode(n) then
@@ -218,6 +220,7 @@ implementation
                    else
                      do_error;
                 end;
+              pasbool64,
               bool64bit :
                 begin
                    if is_constboolnode(n) then
@@ -1434,6 +1437,7 @@ implementation
         storefilepos : tfileposinfo;
         cursectype   : TAsmSectionType;
         hrec         : threc;
+        section : ansistring;
       begin
         { mark the staticvarsym as typedconst }
         include(sym.varoptions,vo_is_typed_const);
@@ -1478,9 +1482,29 @@ implementation
            ) then
           read_public_and_external(sym);
 
+         { try to parse a section directive }
+        if not in_structure and (target_info.system in systems_allow_section) and
+          (symtablestack.top.symtabletype in [staticsymtable,globalsymtable]) and
+           (idtoken=_SECTION) then
+               begin
+                 try_consume_sectiondirective(section);
+                 if section<>'' then
+                   begin
+                     if (sym.varoptions *[vo_is_external,vo_is_weak_external])<>[] then
+                       Message(parser_e_externals_no_section);
+                     if sym.typ<>staticvarsym then
+                       Message(parser_e_section_no_locals);
+                     tstaticvarsym(sym).section:=section;
+                     include(sym.varoptions, vo_has_section);
+                   end;
+               end;
+
         { only now add items based on the symbolname, because it may }
         { have been modified by the directives parsed above          }
-        new_section(list,cursectype,lower(sym.mangledname),const_align(sym.vardef.alignment));
+        if vo_has_section in sym.varoptions then
+          new_section(list,sec_user,sym.section,const_align(sym.vardef.alignment))
+        else
+          new_section(list,cursectype,lower(sym.mangledname),const_align(sym.vardef.alignment));
         if (sym.owner.symtabletype=globalsymtable) or
            create_smartlink or
            (assigned(current_procinfo) and

+ 4 - 3
compiler/ptype.pas

@@ -439,7 +439,7 @@ implementation
                 member_blocktype:=bt_type;
 
                 { local and anonymous records can not have inner types. skip top record symtable }
-                if (current_structdef.objname^='') or 
+                if (current_structdef.objname^='') or
                    not(symtablestack.stack^.next^.symtable.symtabletype in [globalsymtable,staticsymtable,objectsymtable,recordsymtable]) then
                   Message(parser_e_no_types_in_local_anonymous_records);
               end;
@@ -815,7 +815,7 @@ implementation
                                def:=torddef.create(uchar,lv,hv)
                              else
                                if is_boolean(pt1.resultdef) then
-                                 def:=torddef.create(pasbool,lv,hv)
+                                 def:=torddef.create(pasbool8,lv,hv)
                                else if is_signed(pt1.resultdef) then
                                  def:=torddef.create(range_to_basetype(lv,hv),lv,hv)
                                else
@@ -939,7 +939,8 @@ implementation
 {$ifdef cpu64bitaddr}
                     u32bit,s64bit,
 {$endif cpu64bitaddr}
-                    pasbool,bool8bit,bool16bit,bool32bit,bool64bit,
+                    pasbool8,pasbool16,pasbool32,pasbool64,
+                    bool8bit,bool16bit,bool32bit,bool64bit,
                     uwidechar] then
                     begin
                        lowval:=torddef(def).low;

+ 14 - 2
compiler/scandir.pas

@@ -35,6 +35,7 @@ unit scandir;
       tsavedswitchesstate = record
         localsw: tlocalswitches;
         verbosity: longint;
+        pmessage : pmessagestaterecord;
       end;
 
     type
@@ -944,6 +945,9 @@ unit scandir;
       Dec(switchesstatestackpos);
       recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw);
       recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity);
+      pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage;
+      RestoreLocalVerbosity(nil);
+      flushpendingswitchesstate;
     end;
 
     procedure dir_pointermath;
@@ -970,6 +974,7 @@ unit scandir;
       flushpendingswitchesstate;
 
       switchesstatestack[switchesstatestackpos].localsw:= current_settings.localswitches;
+      switchesstatestack[switchesstatestackpos].pmessage:= current_settings.pmessage;
       switchesstatestack[switchesstatestackpos].verbosity:=status.verbosity;
       Inc(switchesstatestackpos);
     end;
@@ -1206,6 +1211,7 @@ unit scandir;
         ident : string;
         state : string;
         msgstate : tmsgstate;
+        i : integer;
       begin
         current_scanner.skipspace;
         ident:=current_scanner.readid;
@@ -1213,6 +1219,7 @@ unit scandir;
         state:=current_scanner.readid;
 
         { support both delphi and fpc switches }
+        { use local ms_on/off/error tmsgstate values }
         if (state='ON') or (state='+') then
           msgstate:=ms_on
         else
@@ -1275,7 +1282,11 @@ unit scandir;
         if ident='ZERO_NIL_COMPAT' then
           recordpendingmessagestate(type_w_zero_to_nil, msgstate)
         else
-          Message1(scanner_w_illegal_warn_identifier,ident);
+          begin
+            i:=0;
+            if not ChangeMessageVerbosity(ident,i,msgstate) then
+              Message1(scanner_w_illegal_warn_identifier,ident);
+          end;
       end;
 
     procedure dir_warning;
@@ -1330,7 +1341,8 @@ unit scandir;
       begin
         current_scanner.skipspace;
         s:=current_scanner.readcomment;
-        UpdateAlignmentStr(s,current_settings.alignment);
+        if not(UpdateAlignmentStr(s,current_settings.alignment)) then
+          message(scanner_e_illegal_alignment_directive);
       end;
 
     procedure dir_codepage;

+ 3 - 2
compiler/sparc/cgcpu.pas

@@ -1052,7 +1052,8 @@ implementation
             begin
               if not((def.typ=pointerdef) or
                     ((def.typ=orddef) and
-                     (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,pasbool]))) then
+                     (torddef(def).ordtype in [u64bit,u16bit,u32bit,u8bit,uchar,
+                                               pasbool8,pasbool16,pasbool32,pasbool64]))) then
                 begin
                   ai:=TAiCpu.Op_sym(A_Bxx,hl);
                   ai.SetCondition(C_NO);
@@ -1363,7 +1364,7 @@ implementation
           Internalerror(200109191);
 
         make_global:=false;
-        if (not current_module.is_unit) or
+        if (not current_module.is_unit) or create_smartlink or
            (procdef.owner.defowner.owner.symtabletype=globalsymtable) then
           make_global:=true;
 

+ 1 - 1
compiler/sparc/ncpucnv.pas

@@ -167,7 +167,7 @@ implementation
                s64real:
                  begin
                    hregister:=cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64);
-                   current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(8)));
+                   new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,l1.name,const_align(8));
                    current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
                    { I got this constant from a test program (FK) }
                    current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit($41f00000));

+ 2 - 2
compiler/sparc/racpugas.pas

@@ -598,14 +598,14 @@ Interface
         fillchar(actcondition,sizeof(actcondition),0);
 
          { Search opcodes }
-         actopcode:=tasmop(PtrInt(iasmops.Find(s)));
+         actopcode:=tasmop(PtrUInt(iasmops.Find(s)));
          if actopcode<>A_NONE then
            begin
              actasmtoken:=AS_OPCODE;
              result:=TRUE;
              exit;
            end;
-           
+
         { not found, check branch instructions }
         if (Upcase(s[1])='B') or
            ((Upcase(s[1])='F') and (Upcase(s[2])='B')) then

+ 24 - 1
compiler/switches.pas

@@ -265,8 +265,14 @@ procedure recordpendingverbosityswitch(sw: char; state: char);
   end;
 
 procedure recordpendingmessagestate(msg: longint; state: tmsgstate);
+  var
+    pstate : pmessagestaterecord;
   begin
-    { todo }
+    new(pstate);
+    pstate^.next:=pendingstate.nextmessagerecord;
+    pstate^.value:=msg;
+    pstate^.state:=state;
+    pendingstate.nextmessagerecord:=pstate;
   end;
 
 procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
@@ -311,6 +317,7 @@ procedure recordpendingcallingswitch(const str: shortstring);
 procedure flushpendingswitchesstate;
   var
     tmpproccal: tproccalloption;
+    fstate, pstate : pmessagestaterecord;
   begin
     { process pending localswitches (range checking, etc) }
     if pendingstate.localswitcheschanged then
@@ -329,6 +336,22 @@ procedure flushpendingswitchesstate;
         setverbosity(pendingstate.nextverbositystr);
         pendingstate.nextverbositystr:='';
       end;
+    fstate:=pendingstate.nextmessagerecord;
+    pstate:=pendingstate.nextmessagerecord;
+    while assigned(pstate) do
+      begin
+        pendingstate.nextmessagerecord:=pstate^.next;
+        SetMessageVerbosity(pstate^.value,pstate^.state);
+        if not assigned(pstate^.next) then
+          begin
+            pstate^.next:=current_settings.pmessage;
+            current_settings.pmessage:=fstate;
+            pstate:=nil;
+          end
+        else
+          pstate:=pstate^.next;
+        pendingstate.nextmessagerecord:=nil;
+      end;
     { process pending calling convention changes (calling x) }
     if pendingstate.nextcallingstr<>'' then
       begin

+ 2 - 1
compiler/symconst.pas

@@ -210,7 +210,8 @@ type
     uvoid,
     u8bit,u16bit,u32bit,u64bit,
     s8bit,s16bit,s32bit,s64bit,
-    pasbool,bool8bit,bool16bit,bool32bit,bool64bit,
+    pasbool8,pasbool16,pasbool32,pasbool64,
+    bool8bit,bool16bit,bool32bit,bool64bit,
     uchar,uwidechar,scurrency
   );
 

+ 87 - 9
compiler/symdef.pas

@@ -677,7 +677,10 @@ interface
        voidtype,                  { Void (procedure) }
        cchartype,                 { Char }
        cwidechartype,             { WideChar }
-       booltype,                  { boolean type }
+       pasbool8type,              { boolean type }
+       pasbool16type,
+       pasbool32type,
+       pasbool64type,
        bool8type,
        bool16type,
        bool32type,
@@ -786,6 +789,8 @@ interface
 {$endif AVR}
 
     function make_mangledname(const typeprefix:string;st:TSymtable;const suffix:string):string;
+    function make_dllmangledname(const dllname,importname:string;
+                                 import_nr : word; pco : tproccalloption):string;
 
     { should be in the types unit, but the types unit uses the node stuff :( }
     function is_interfacecom(def: tdef): boolean;
@@ -935,6 +940,68 @@ implementation
           result := '_' + result;
       end;
 
+    function make_dllmangledname(const dllname,importname:string;import_nr : word; pco : tproccalloption):string;
+       var
+         crc : cardinal;
+         i : longint;
+         use_crc : boolean;
+         dllprefix : string;
+      begin
+        if (target_info.system in (systems_all_windows + systems_nativent +
+                           [system_i386_emx, system_i386_os2]))
+            and (dllname <> '') then
+          begin
+            dllprefix:=lower(ExtractFileName(dllname));
+            { Remove .dll suffix if present }
+            if copy(dllprefix,length(dllprefix)-3,length(dllprefix))='.dll' then
+              dllprefix:=copy(dllprefix,1,length(dllprefix)-4);
+            use_crc:=false;
+            for i:=1 to length(dllprefix) do
+              if not (dllprefix[i] in ['a'..'z','A'..'Z','_','0'..'9']) then
+                begin
+                  use_crc:=true;
+                  break;
+                end;
+            if use_crc then
+              begin
+                crc:=0;
+                crc:=UpdateCrc32(crc,dllprefix[1],length(dllprefix));
+                dllprefix:='_$dll$crc$'+hexstr(crc,8)+'$';
+              end
+            else
+              dllprefix:='_$dll$'+dllprefix+'$';
+
+            if importname<>'' then
+              result:=dllprefix+importname
+            else
+              result:=dllprefix+'_index_'+tostr(import_nr);
+            { Replace ? and @ in import name, since GNU AS does not allow these characters in symbol names. }
+            { This allows to import VC++ mangled names from DLLs. }
+            { Do not perform replacement, if external symbol is not imported from DLL. }
+            if (dllname<>'') then
+              begin
+                Replace(result,'?','__q$$');
+    {$ifdef arm}
+                { @ symbol is not allowed in ARM assembler only }
+                Replace(result,'@','__a$$');
+    {$endif arm}
+             end;
+          end
+        else
+          begin
+            if importname<>'' then
+             begin
+               if not(pco in [pocall_cdecl,pocall_cppdecl]) then
+                 result:=importname
+               else
+                 result:=target_info.Cprefix+importname;
+             end
+            else
+              result:='_index_'+tostr(import_nr);
+          end;
+
+      end;
+
 {****************************************************************************
            TDEFAWARESYMTABLESTACK
            (symtablestack descendant that does some special actions on
@@ -1766,7 +1833,8 @@ implementation
           0,
           1,2,4,8,
           1,2,4,8,
-          1,1,2,4,8,
+          1,2,4,8,
+          1,2,4,8,
           1,2,8
         );
       begin
@@ -1815,7 +1883,8 @@ implementation
           varUndefined,
           varbyte,varword,varlongword,varqword,
           varshortint,varsmallint,varinteger,varint64,
-          varboolean,varboolean,varboolean,varUndefined,varUndefined,
+          varboolean,varboolean,varboolean,varboolean,
+          varboolean,varboolean,varUndefined,varUndefined,
           varUndefined,varUndefined,varCurrency);
       begin
         result:=basetype2vardef[ordtype];
@@ -1844,7 +1913,8 @@ implementation
           'untyped',
           'Byte','Word','DWord','QWord',
           'ShortInt','SmallInt','LongInt','Int64',
-          'Boolean','ByteBool','WordBool','LongBool','QWordBool',
+          'Boolean','Boolean16','Boolean32','Boolean64',
+          'ByteBool','WordBool','LongBool','QWordBool',
           'Char','WideChar','Currency');
 
       begin
@@ -3474,8 +3544,10 @@ implementation
          else
            import_name:=nil;
          import_nr:=ppufile.getword;
+{$ifdef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
          if target_info.system in systems_interrupt_table then
            interruptvector:=ppufile.getlongint;
+{$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
          if (po_msgint in procoptions) then
            messageinf.i:=ppufile.getlongint;
          if (po_msgstr in procoptions) then
@@ -3612,8 +3684,10 @@ implementation
          if po_has_importname in procoptions then
            ppufile.putstring(import_name^);
          ppufile.putword(import_nr);
+{$ifdef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
          if target_info.system in systems_interrupt_table then
            ppufile.putlongint(interruptvector);
+{$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
          if (po_msgint in procoptions) then
            ppufile.putlongint(messageinf.i);
          if (po_msgstr in procoptions) then
@@ -3929,7 +4003,8 @@ implementation
              'v',
              'h','t','j','y',
              'a','s','i','x',
-             'b','b','b','b','b',
+             'b','b','b','b',
+             'b','b','b','b',
              'c','w','x');
 
            floattype2str : array[tfloattype] of string[1] = (
@@ -5275,7 +5350,7 @@ implementation
               begin
                 { copied from psub.read_proc }
                 if assigned(tobjectdef(pd.struct).import_lib) then
-                   current_module.AddExternalImport(tobjectdef(pd.struct).import_lib^,pd.mangledname,0,false,false)
+                   current_module.AddExternalImport(tobjectdef(pd.struct).import_lib^,pd.mangledname,pd.mangledname,0,false,false)
                  else
                    begin
                      { add import name to external list for DLL scanning }
@@ -5420,15 +5495,18 @@ implementation
     function TImplementedInterface.getcopy:TImplementedInterface;
       begin
         Result:=TImplementedInterface.Create(nil);
-        {$warning: this is completely wrong on so many levels...}
         { 1) the procdefs list will be freed once for each copy
           2) since the procdefs list owns its elements, those will also be freed for each copy
           3) idem for the name mappings
         }
+        { warning: this is completely wrong on so many levels...
         Move(pointer(self)^,pointer(result)^,InstanceSize);
+        We need to make clean copies of the different fields
+        this is not implemented yet, and thus we generate an internal
+        error instead PM 2011-06-14 }
+        internalerror(2011061401);
       end;
 
-
 {****************************************************************************
                                 TFORWARDDEF
 ****************************************************************************}
@@ -5705,7 +5783,7 @@ implementation
         result:=
           assigned(def) and
           (def.typ=objectdef) and
-          (tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba,odt_dispinterface,odt_objcclass,odt_objcprotocol]);
+          (tobjectdef(def).objecttype in [odt_class,odt_interfacecom,odt_interfacecorba,odt_dispinterface,odt_objcclass,odt_objcprotocol,odt_helper]);
       end;
 
     function is_class_or_object(def: tdef): boolean;

+ 3 - 4
compiler/symtable.pas

@@ -2560,6 +2560,7 @@ implementation
         st: tsymtable;
       begin
         result:=false;
+        odef:=nil;
         { when there are no helpers active currently then we don't need to do
           anything }
         if current_module.extendeddefs.count=0 then
@@ -2911,8 +2912,7 @@ implementation
              else
                initialmacrosymtable.insert(mac);
            end;
-         if not mac.defined then
-           Message1(parser_c_macro_defined,mac.name);
+         Message1(parser_c_macro_defined,mac.name);
          mac.defined:=true;
       end;
 
@@ -2993,8 +2993,7 @@ implementation
            {If not found, then it's already undefined.}
          else
            begin
-             if mac.defined then
-               Message1(parser_c_macro_undefined,mac.name);
+             Message1(parser_c_macro_undefined,mac.name);
              mac.defined:=false;
              mac.is_compiler_var:=false;
              { delete old definition }

+ 216 - 0
compiler/systems.inc

@@ -0,0 +1,216 @@
+{
+    Copyright (c) 1998-2008 by Florian Klaempfl
+
+    This include contains the enumeration
+    information about the target systems supported
+    (these are not processor specific)
+
+    This program is free software; you can redistribute it and/or modify
+    iu under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge- MA 02139, USA.
+
+ ****************************************************************************
+}
+   type
+       tendian = (endian_little,endian_big);
+
+     (*
+       IMPORTANT NOTE:
+       The value of this enumeration is stored in PPU files.
+       Therefore adding new CPU targets should not change the
+       values of the pre-existing targets. (CEC)
+       FURTHERMORE : Make sure that this branch values, are
+       consistant with the main branch version always.
+     *)
+       tsystemcpu=
+       (
+             cpu_no,                       { 0 }
+             cpu_i386,                     { 1 }
+             cpu_m68k,                     { 2 }
+             cpu_alpha,                    { 3 }
+             cpu_powerpc,                  { 4 }
+             cpu_sparc,                    { 5 }
+             cpu_vm,                       { 6 }
+             cpu_iA64,                     { 7 }
+             cpu_x86_64,                   { 8 }
+             cpu_mips,                     { 9 }
+             cpu_arm,                      { 10 }
+             cpu_powerpc64,                { 11 }
+             cpu_avr,                      { 12 }
+             cpu_mipsel                    { 13 }
+       );
+
+       tasmmode= (asmmode_none
+            { standard assembler (cpu dependant) with full parsing }
+            ,asmmode_standard
+            ,asmmode_i386_att
+            ,asmmode_i386_intel
+            ,asmmode_ppc_gas
+            ,asmmode_ppc_motorola
+            ,asmmode_arm_gas
+            ,asmmode_sparc_gas
+            ,asmmode_x86_64_gas
+            ,asmmode_m68k_mot
+            ,asmmode_x86_64_intel
+            ,asmmode_x86_64_att
+            ,asmmode_avr_gas
+       );
+
+     (* IMPORTANT NOTE:
+       the integer value of this enum is stored in PPU
+       files to recognize the target, so if you add new targets
+       allways add them at end PM
+       FURTHERMORE : Make sure that this branch values are
+       consistant with the main branch version always. (CEC)
+       *)
+     type
+       tsystem =
+       (
+             system_none,               { 0 }
+             obsolete_system_i386_GO32V1,{ 1 }
+             system_i386_GO32V2,        { 2 }
+             system_i386_linux,         { 3 }
+             system_i386_OS2,           { 4 }
+             system_i386_Win32,         { 5 }
+             system_i386_freebsd,       { 6 }
+             system_m68k_Amiga,         { 7 }
+             system_m68k_Atari,         { 8 }
+             system_m68k_Mac,           { 9 }
+             system_m68k_linux,         { 10 }
+             system_m68k_PalmOS,        { 11 }
+             system_alpha_linux,        { 12 }
+             system_powerpc_linux,      { 13 }
+             system_powerpc_macos,      { 14 }
+             system_i386_solaris,       { 15 }
+             system_i386_beos,          { 16 }
+             system_i386_netbsd,        { 17 }
+             system_m68k_netbsd,        { 18 }
+             system_i386_Netware,       { 19 }
+             system_i386_qnx,           { 20 }
+             system_i386_wdosx,         { 21 }
+             system_sparc_solaris,      { 22 }
+             system_sparc_linux,        { 23 }
+             system_i386_openbsd,       { 24 }
+             system_m68k_openbsd,       { 25 }
+             system_x86_64_linux,       { 26 }
+             system_powerpc_darwin,     { 27 }
+             system_i386_EMX,           { 28 }
+             system_powerpc_netbsd,     { 29 }
+             system_powerpc_openbsd,    { 30 }
+             system_arm_linux,          { 31 }
+             system_i386_watcom,        { 32 }
+             system_powerpc_MorphOS,    { 33 }
+             system_x86_64_freebsd,     { 34 }
+             system_i386_netwlibc,      { 35 }
+             system_powerpc_Amiga,      { 36 }
+             system_x86_64_win64,       { 37 }
+             system_arm_wince,          { 38 }
+             system_ia64_win64,         { 39 }
+             system_i386_wince,         { 40 }
+             system_x86_6432_linux,     { 41 }
+             system_arm_gba,            { 42 }
+             system_powerpc64_linux,    { 43 }
+             system_i386_darwin,        { 44 }
+             system_arm_palmos,         { 45 }
+             system_powerpc64_darwin,   { 46 }
+             system_arm_nds,            { 47 }
+             system_i386_embedded,      { 48 }
+             system_m68k_embedded,      { 49 }
+             system_alpha_embedded,     { 50 }
+             system_powerpc_embedded,   { 51 }
+             system_sparc_embedded,     { 52 }
+             system_vm_embedded,        { 53 }
+             system_iA64_embedded,      { 54 }
+             system_x86_64_embedded,    { 55 }
+             system_mips_embedded,      { 56 }
+             system_arm_embedded,       { 57 }
+             system_powerpc64_embedded, { 58 }
+             system_i386_symbian,       { 59 }
+             system_arm_symbian,        { 60 }
+             system_x86_64_darwin,      { 61 }
+             system_avr_embedded,       { 62 }
+             system_i386_haiku,         { 63 }
+             system_arm_darwin,         { 64 }
+             system_x86_64_solaris,     { 65 }
+             system_mips_linux,         { 66 }
+             system_mipsel_linux,       { 67 }
+             system_i386_nativent,      { 68 }
+             system_i386_iphonesim,     { 69 }
+             system_powerpc_wii         { 70 }
+       );
+
+     type
+       tasm = (as_none
+             ,as_gas                   { standard gnu assembler }
+             ,as_i386_as_aout
+             ,as_i386_nasmcoff
+             ,as_i386_nasmwin32
+             ,as_i386_nasmwdosx
+             ,as_i386_nasmelf
+             ,as_i386_nasmobj
+             ,as_i386_nasmbeos
+             ,as_i386_tasm
+             ,as_i386_masm
+             ,as_i386_wasm
+             ,as_i386_coff
+             ,as_i386_pecoff
+             ,as_i386_elf32
+             ,as_i386_pecoffwdosx
+             ,as_m68k_mit
+             ,as_powerpc_mpw
+             ,as_darwin
+             ,as_i386_macho
+             ,as_x86_64_masm
+             ,as_x86_64_pecoff
+             ,as_i386_pecoffwince
+             ,as_arm_pecoffwince
+             ,as_x86_64_elf64
+             ,as_sparc_elf32
+             ,as_ggas                  { gnu assembler called "gas" instead of "as" }
+             ,as_i386_nasmhaiku
+             ,as_powerpc_vasm
+             ,as_i386_nlmcoff
+       );
+
+       tar = (ar_none
+            ,ar_gnu_ar
+            ,ar_mpw_ar
+            ,ar_gnu_ar_scripted
+            ,ar_gnu_gar
+       );
+
+       tres = (res_none
+            ,res_gnu_windres,res_watcom_wrc_os2
+            ,res_m68k_palmos,res_m68k_mpw
+            ,res_powerpc_mpw,res_elf
+            ,res_win64_gorc, res_macho, res_ext
+       );
+
+       tresinfoflags = (res_external_file,res_arch_in_file_name
+            ,res_single_file);
+
+       tdbg = (dbg_none
+            ,dbg_stabs,dbg_dwarf2,dbg_dwarf3,dbg_dwarf4
+       );
+
+       tscripttype = (script_none
+            ,script_dos,script_unix,script_amiga,
+            script_mpw
+       );
+
+       tabi = (abi_default
+            ,abi_powerpc_sysv,abi_powerpc_aix
+            ,abi_eabi,abi_armeb
+       );
+
+

+ 51 - 212
compiler/systems.pas

@@ -26,198 +26,7 @@ unit systems;
 
 interface
 
-
-   type
-       tendian = (endian_little,endian_big);
-
-     (*
-       IMPORTANT NOTE:
-       The value of this enumeration is stored in PPU files.
-       Therefore adding new CPU targets should not change the
-       values of the pre-existing targets. (CEC)
-       FURTHERMORE : Make sure that this branch values, are
-       consistant with the main branch version always.
-     *)
-       tsystemcpu=
-       (
-             cpu_no,                       { 0 }
-             cpu_i386,                     { 1 }
-             cpu_m68k,                     { 2 }
-             cpu_alpha,                    { 3 }
-             cpu_powerpc,                  { 4 }
-             cpu_sparc,                    { 5 }
-             cpu_vm,                       { 6 }
-             cpu_iA64,                     { 7 }
-             cpu_x86_64,                   { 8 }
-             cpu_mips,                     { 9 }
-             cpu_arm,                      { 10 }
-             cpu_powerpc64,                { 11 }
-             cpu_avr,                      { 12 }
-             cpu_mipsel                    { 13 }
-       );
-
-       tasmmode= (asmmode_none
-            { standard assembler (cpu dependant) with full parsing }
-            ,asmmode_standard
-            ,asmmode_i386_att
-            ,asmmode_i386_intel
-            ,asmmode_ppc_gas
-            ,asmmode_ppc_motorola
-            ,asmmode_arm_gas
-            ,asmmode_sparc_gas
-            ,asmmode_x86_64_gas
-            ,asmmode_m68k_mot
-            ,asmmode_x86_64_intel
-            ,asmmode_x86_64_att
-            ,asmmode_avr_gas
-       );
-
-     (* IMPORTANT NOTE:
-       the integer value of this enum is stored in PPU
-       files to recognize the target, so if you add new targets
-       allways add them at end PM
-       FURTHERMORE : Make sure that this branch values are
-       consistant with the main branch version always. (CEC)
-       *)
-     type
-       tsystem =
-       (
-             system_none,               { 0 }
-             obsolete_system_i386_GO32V1,{ 1 }
-             system_i386_GO32V2,        { 2 }
-             system_i386_linux,         { 3 }
-             system_i386_OS2,           { 4 }
-             system_i386_Win32,         { 5 }
-             system_i386_freebsd,       { 6 }
-             system_m68k_Amiga,         { 7 }
-             system_m68k_Atari,         { 8 }
-             system_m68k_Mac,           { 9 }
-             system_m68k_linux,         { 10 }
-             system_m68k_PalmOS,        { 11 }
-             system_alpha_linux,        { 12 }
-             system_powerpc_linux,      { 13 }
-             system_powerpc_macos,      { 14 }
-             system_i386_solaris,       { 15 }
-             system_i386_beos,          { 16 }
-             system_i386_netbsd,        { 17 }
-             system_m68k_netbsd,        { 18 }
-             system_i386_Netware,       { 19 }
-             system_i386_qnx,           { 20 }
-             system_i386_wdosx,         { 21 }
-             system_sparc_solaris,      { 22 }
-             system_sparc_linux,        { 23 }
-             system_i386_openbsd,       { 24 }
-             system_m68k_openbsd,       { 25 }
-             system_x86_64_linux,       { 26 }
-             system_powerpc_darwin,     { 27 }
-             system_i386_EMX,           { 28 }
-             system_powerpc_netbsd,     { 29 }
-             system_powerpc_openbsd,    { 30 }
-             system_arm_linux,          { 31 }
-             system_i386_watcom,        { 32 }
-             system_powerpc_MorphOS,    { 33 }
-             system_x86_64_freebsd,     { 34 }
-             system_i386_netwlibc,      { 35 }
-             system_powerpc_Amiga,      { 36 }
-             system_x86_64_win64,       { 37 }
-             system_arm_wince,          { 38 }
-             system_ia64_win64,         { 39 }
-             system_i386_wince,         { 40 }
-             system_x86_6432_linux,     { 41 }
-             system_arm_gba,            { 42 }
-             system_powerpc64_linux,    { 43 }
-             system_i386_darwin,        { 44 }
-             system_arm_palmos,         { 45 }
-             system_powerpc64_darwin,   { 46 }
-             system_arm_nds,            { 47 }
-             system_i386_embedded,      { 48 }
-             system_m68k_embedded,      { 49 }
-             system_alpha_embedded,     { 50 }
-             system_powerpc_embedded,   { 51 }
-             system_sparc_embedded,     { 52 }
-             system_vm_embedded,        { 53 }
-             system_iA64_embedded,      { 54 }
-             system_x86_64_embedded,    { 55 }
-             system_mips_embedded,      { 56 }
-             system_arm_embedded,       { 57 }
-             system_powerpc64_embedded, { 58 }
-             system_i386_symbian,       { 59 }
-             system_arm_symbian,        { 60 }
-             system_x86_64_darwin,      { 61 }
-             system_avr_embedded,       { 62 }
-             system_i386_haiku,         { 63 }
-             system_arm_darwin,         { 64 }
-             system_x86_64_solaris,     { 65 }
-             system_mips_linux,         { 66 }
-             system_mipsel_linux,       { 67 }
-             system_i386_nativent,      { 68 }
-             system_i386_iphonesim,     { 69 }
-             system_powerpc_wii         { 70 }
-       );
-
-     type
-       tasm = (as_none
-             ,as_gas                   { standard gnu assembler }
-             ,as_i386_as_aout
-             ,as_i386_nasmcoff
-             ,as_i386_nasmwin32
-             ,as_i386_nasmwdosx
-             ,as_i386_nasmelf
-             ,as_i386_nasmobj
-             ,as_i386_nasmbeos
-             ,as_i386_tasm
-             ,as_i386_masm
-             ,as_i386_wasm
-             ,as_i386_coff
-             ,as_i386_pecoff
-             ,as_i386_elf32
-             ,as_i386_pecoffwdosx
-             ,as_m68k_mit
-             ,as_powerpc_mpw
-             ,as_darwin
-             ,as_i386_macho
-             ,as_x86_64_masm
-             ,as_x86_64_pecoff
-             ,as_i386_pecoffwince
-             ,as_arm_pecoffwince
-             ,as_x86_64_elf64
-             ,as_sparc_elf32
-             ,as_ggas                  { gnu assembler called "gas" instead of "as" }
-             ,as_i386_nasmhaiku
-             ,as_powerpc_vasm
-             ,as_i386_nlmcoff
-       );
-
-       tar = (ar_none
-            ,ar_gnu_ar
-            ,ar_mpw_ar
-            ,ar_gnu_ar_scripted
-            ,ar_gnu_gar
-       );
-
-       tres = (res_none
-            ,res_gnu_windres,res_watcom_wrc_os2
-            ,res_m68k_palmos,res_m68k_mpw
-            ,res_powerpc_mpw,res_elf
-            ,res_win64_gorc, res_macho, res_ext
-       );
-
-       tresinfoflags = (res_external_file,res_arch_in_file_name
-            ,res_single_file);
-
-       tdbg = (dbg_none
-            ,dbg_stabs,dbg_dwarf2,dbg_dwarf3,dbg_dwarf4
-       );
-
-       tscripttype = (script_none
-            ,script_dos,script_unix,script_amiga,
-            script_mpw
-       );
-
-       tabi = (abi_default
-            ,abi_powerpc_sysv,abi_powerpc_aix
-            ,abi_eabi,abi_armeb
-       );
+{$i systems.inc}
 
 {*****************************************************************************
                                Structures
@@ -408,6 +217,7 @@ interface
 
        { all real windows systems, no cripple ones like wince, wdosx et. al. }
        systems_windows = [system_i386_win32,system_x86_64_win64,system_ia64_win64];
+
        { all windows systems }
        systems_all_windows = [system_i386_win32,system_x86_64_win64,system_ia64_win64,
                              system_arm_wince,system_i386_wince];
@@ -421,12 +231,6 @@ interface
        systems_solaris = [system_sparc_solaris, system_i386_solaris,
 			  system_x86_64_solaris];
 
-       { systems supporting Objective-C }
-       systems_objc_supported = systems_darwin;
-
-       { systems using the non-fragile Objective-C ABI }
-       systems_objc_nfabi = [system_powerpc64_darwin,system_x86_64_darwin,system_arm_darwin,system_i386_iphonesim];
-
        { all embedded systems }
        systems_embedded = [system_i386_embedded,system_m68k_embedded,
                            system_alpha_embedded,system_powerpc_embedded,
@@ -435,6 +239,33 @@ interface
                            system_mips_embedded,system_arm_embedded,
                            system_powerpc64_embedded];
 
+       { all systems that allow section directive }
+       systems_allow_section = systems_embedded;
+
+       systems_allow_section_no_semicolon = systems_allow_section
+{$ifdef TEST_TLS_DIRECTORY}
+       + systems_windows
+{$endif TEST_TLS_DIRECTORY}
+       ;
+
+       { all symbian systems }
+       systems_symbian = [system_i386_symbian,system_arm_symbian];
+
+       { all classic Mac OS targets }
+       systems_macos = [system_m68k_Mac,system_powerpc_Macos];
+
+       { all OS/2 targets }
+       systems_os2 = [system_i386_OS2,system_i386_emx];
+
+       { all native nt systems }
+       systems_nativent = [system_i386_nativent];
+
+       { systems supporting Objective-C }
+       systems_objc_supported = systems_darwin;
+
+       { systems using the non-fragile Objective-C ABI }
+       systems_objc_nfabi = [system_powerpc64_darwin,system_x86_64_darwin,system_arm_darwin,system_i386_iphonesim];
+
        { all systems supporting exports from programs or units }
        systems_unit_program_exports = [system_i386_win32,
                                          system_i386_wdosx,
@@ -449,13 +280,14 @@ interface
 
        systems_internal_sysinit = [system_i386_linux,system_i386_win32];
 
+       {$ifdef FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
+       { If anyone wants to use interrupt for
+         a specific target, add a
+         $define FPC_HAS_SYSTEMS_INTERRUPT_TABLE
+         to fpcdefs.inc to reactivate
+         the corresponding code }
        systems_interrupt_table = [{system_arm_embedded}];
-
-       { all symbian systems }
-       systems_symbian = [system_i386_symbian,system_arm_symbian];
-
-       { all native nt systems }
-       systems_nativent = [system_i386_nativent];
+       {$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
 
        { all systems for which istack must be at a 16 byte boundary
          when calling a function }
@@ -505,7 +337,7 @@ interface
 
     procedure set_source_info(const ti : tsysteminfo);
 
-    procedure UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo);
+    function UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo) : boolean;
 
     procedure RegisterTarget(const r:tsysteminfo);
     procedure RegisterRes(const r:tresinfo; rcf : TAbstractResourceFileClass);
@@ -697,19 +529,26 @@ begin
 end;
 
 
-procedure UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo);
+function UpdateAlignment(var d:talignmentinfo;const s:talignmentinfo) : boolean;
 begin
+  result:=true;
   with d do
    begin
+     if (s.procalign in [1,2,4,8,16,32,64,128]) or (s.procalign=256) then
+       procalign:=s.procalign
+     else if s.procalign<>0 then
+       result:=false;
+     if (s.loopalign in [1,2,4,8,16,32,64,128]) or (s.loopalign=256) then
+       loopalign:=s.loopalign
+     else if s.loopalign<>0 then
+       result:=false;
+     if (s.jumpalign in [1,2,4,8,16,32,64,128]) or (s.jumpalign=256) then
+       jumpalign:=s.jumpalign
+     else if s.jumpalign<>0 then
+       result:=false;
      { general update rules:
        minimum: if higher then update
        maximum: if lower then update or if undefined then update }
-     if s.procalign>procalign then
-      procalign:=s.procalign;
-     if s.loopalign>loopalign then
-      loopalign:=s.loopalign;
-     if s.jumpalign>jumpalign then
-      jumpalign:=s.jumpalign;
      if s.constalignmin>constalignmin then
       constalignmin:=s.constalignmin;
      if (constalignmax=0) or

+ 1 - 1
compiler/systems/i_linux.pas

@@ -414,7 +414,7 @@ unit i_linux;
             shortname    : 'Linux';
             flags        : [tf_needs_symbol_size,tf_needs_dwarf_cfi,tf_smartlink_library,
                             tf_library_needs_pic,tf_needs_symbol_type,tf_files_case_sensitive,
-                            tf_has_winlike_resources];
+                            tf_has_winlike_resources,tf_safecall_exceptions,tf_safecall_clearstack];
             cpu          : cpu_x86_64;
             unit_env     : 'LINUXUNITS';
             extradefines : 'UNIX;HASUNIX';

+ 4 - 3
compiler/systems/t_emx.pas

@@ -279,7 +279,7 @@ begin
 end;
 
 
-procedure AddImport(const module:string;index:longint;const name:string);
+procedure AddImport(const module:string;index:longint;const name,mangledname:string);
 {func       = Name of function to import.
  module     = Name of DLL to import from.
  index      = Index of function in DLL. Use 0 to import by name.
@@ -290,7 +290,7 @@ var tmp1,tmp2,tmp3:string;
     func : string;
 begin
     aout_init;
-    func:='';
+    func:=mangledname;
     tmp2:=func;
     if profile_flag and not (copy(func,1,4)='_16_') then
         begin
@@ -353,7 +353,8 @@ end;
             for j:=0 to ImportLibrary.ImportSymbolList.Count-1 do
               begin
                 ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
-                AddImport(ImportLibrary.Name,ImportSymbol.OrdNr,ImportSymbol.Name);
+                AddImport(ImportLibrary.Name,ImportSymbol.OrdNr,
+                  ImportSymbol.Name,ImportSymbol.MangledName);
               end;
             close(out_file);
          end;

+ 5 - 14
compiler/systems/t_linux.pas

@@ -192,6 +192,9 @@ begin
 {$endif FPC_ARMEL}
 {$endif arm}
 
+{$ifdef mips}
+     defdynlinker:='/lib/ld.so.1';
+{$endif mips}
      {
        Search order:
          glibc 2.1+
@@ -389,18 +392,12 @@ begin
          if librarysearchpath.FindFile('crti.o',false,s) then
            AddFileName(s);
          { then the crtbegin* }
-         { x86_64 requires this to use entry/exit code with pic,
-           see also issue #8210 regarding a discussion
-           no idea about the other non i386 CPUs (FK)
-         }
-{$ifdef x86_64}
-         if current_module.islibrary then
+         if cs_create_pic in current_settings.moduleswitches then
            begin
              if librarysearchpath.FindFile('crtbeginS.o',false,s) then
                AddFileName(s);
            end
          else
-{$endif x86_64}
            if (cs_link_staticflag in current_settings.globalswitches) and
               librarysearchpath.FindFile('crtbeginT.o',false,s) then
              AddFileName(s)
@@ -484,15 +481,9 @@ begin
       { objects which must be at the end }
       if linklibc and (libctype<>uclibc) then
        begin
-         { x86_64 requires this to use entry/exit code with pic,
-           see also issue #8210 regarding a discussion
-           no idea about the other non i386 CPUs (FK)
-         }
-{$ifdef x86_64}
-         if current_module.islibrary then
+         if cs_create_pic in current_settings.moduleswitches then
            found1:=librarysearchpath.FindFile('crtendS.o',false,s1)
          else
-{$endif x86_64}
            found1:=librarysearchpath.FindFile('crtend.o',false,s1);
          found2:=librarysearchpath.FindFile('crtn.o',false,s2);
          if found1 or found2 then

+ 4 - 14
compiler/systems/t_nds.pas

@@ -451,16 +451,11 @@ begin
         add('		*(.bss*)');
         add('		*(COMMON)');
         add('		. = ALIGN(4);    /* REQUIRED. LD is flaky without it. */');
-        add('		__bss_end = ABSOLUTE(.) ;');
-        add('		__bss_end__ = __bss_end ;');
+        add('		__bss_end__ = ABSOLUTE(.) ;');
+        add('		__end__ = ABSOLUTE(.) ;');
         add('	} AT>ewram');
         add('');
         add('');
-        add(' _end = __bss_end__ ;');
-        add(' __end__ = __bss_end__ ;');
-        add('');
-        add('');
-        add('');
         add('	/* Stabs debugging sections.  */');
         add('	.stab 0 : { *(.stab) }');
         add('	.stabstr 0 : { *(.stabstr) }');
@@ -650,15 +645,10 @@ begin
         add('		*(.bss*)');
         add('		*(COMMON)');
         add('		. = ALIGN(4);    /* REQUIRED. LD is flaky without it. */');
+        add('		__bss_end__ = ABSOLUTE(.);');
+        add('		__end__ = ABSOLUTE(.);');
         add('	} >iwram');
         add('');
-        add('	__bss_end = . ;');
-        add('	__bss_end__ = . ;');
-        add('');
-        add('	_end = . ;');
-        add('	__end__ = . ;');
-        add('	PROVIDE (end = _end);');
-        add('');
         add('	/* Stabs debugging sections.  */');
         add('	.stab 0 : { *(.stab) }');
         add('	.stabstr 0 : { *(.stabstr) }');

+ 2 - 1
compiler/systems/t_nwm.pas

@@ -939,7 +939,7 @@ end;
             s := trimspace(s);
             if (length(s) > 0) then
               if copy(s,1,1) <> '#' then
-                AddImportSymbol('!clib',s,0,false);
+                AddImportSymbol('!clib',s,s,0,false);
           end;
         close(t);
       end;
@@ -971,6 +971,7 @@ end;
     Function  TInternalLinkerNetware.MakeSharedLibrary:boolean;
     begin
       Comment(V_Error,'Make shared library not supported for netware');
+      MakeSharedLibrary := false;
     end;
 
 {*****************************************************************************

+ 9 - 7
compiler/systems/t_os2.pas

@@ -279,24 +279,25 @@ begin
 end;
 
 
-procedure AddImport(const module:string;index:longint;const name:string);
-{func       = Name of function to import.
+procedure AddImport(const module:string;index:longint;const name,mangledname:string);
+{mangledname= Assembler label of the function to import.
  module     = Name of DLL to import from.
  index      = Index of function in DLL. Use 0 to import by name.
  name       = Name of function in DLL. Ignored when index=0;}
 (*
 var tmp1,tmp2,tmp3:string;
 *)
-var tmp1,tmp3:string;
+var tmp1,tmp2,tmp3:string;
     sym_mcount,sym_import:longint;
     fixup_mcount,fixup_import:longint;
 begin
     aout_init;
+    tmp2:=mangledname;
 (*
     tmp2:=func;
     if profile_flag and not (copy(func,1,4)='_16_') then
 *)
-    if profile_flag and not (copy(Name,1,4)='_16_') then
+    if profile_flag and not (copy(tmp2,1,4)='_16_') then
         begin
             {sym_entry:=aout_sym(func,n_text+n_ext,0,0,aout_text_size);}
             sym_mcount:=aout_sym('__mcount',n_ext,0,0,0);
@@ -306,7 +307,7 @@ begin
             tmp2:='__$U_'+func;
             sym_import:=aout_sym(tmp2,n_ext,0,0,0);
 *)
-            sym_import:=aout_sym(name,n_ext,0,0,0);
+            sym_import:=aout_sym(tmp2,n_ext,0,0,0);
             aout_text_byte($55);    {push ebp}
             aout_text_byte($89);    {mov ebp, esp}
             aout_text_byte($e5);
@@ -340,7 +341,7 @@ begin
         tmp3:=func+'='+module+'.'+name;
     aout_sym(tmp2,n_imp1+n_ext,0,0,0);
 *)
-    aout_sym(Name,n_imp1+n_ext,0,0,0);
+    aout_sym(tmp2,n_imp1+n_ext,0,0,0);
     aout_sym(tmp3,n_imp2+n_ext,0,0,0);
     aout_finish;
     write_ar(tmp1,aout_size);
@@ -369,7 +370,8 @@ end;
             for j:=0 to ImportLibrary.ImportSymbolList.Count-1 do
               begin
                 ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
-                AddImport(ChangeFileExt(ExtractFileName(ImportLibrary.Name),''),ImportSymbol.OrdNr,ImportSymbol.Name);
+                AddImport(ChangeFileExt(ExtractFileName(ImportLibrary.Name),''),
+                  ImportSymbol.OrdNr,ImportSymbol.Name,ImportSymbol.MangledName);
               end;
          end;
          close(out_file);

+ 64 - 4
compiler/systems/t_win.pas

@@ -986,19 +986,33 @@ implementation
             Concat('  SYMBOL ___CTOR_LIST__');
             Concat('  SYMBOL __CTOR_LIST__');
             Concat('  LONG -1');
+{$ifdef x86_64}
+            Concat('  LONG -1');
+{$endif x86_64}
             Concat('  OBJSECTION .ctor*');
             Concat('  LONG 0');
+{$ifdef x86_64}
+            Concat('  LONG 0');
+{$endif x86_64}
             Concat('  SYMBOL ___DTOR_LIST__');
             Concat('  SYMBOL __DTOR_LIST__');
             Concat('  LONG -1');
+{$ifdef x86_64}
+            Concat('  LONG -1');
+{$endif x86_64}
             Concat('  OBJSECTION .dtor*');
             Concat('  LONG 0');
+{$ifdef x86_64}
+            Concat('  LONG 0');
+{$endif x86_64}
             Concat('  SYMBOL etext');
             Concat('ENDEXESECTION');
             Concat('EXESECTION .data');
             Concat('  SYMBOL __data_start__');
             Concat('  OBJSECTION .data*');
             Concat('  OBJSECTION .fpc*');
+            Concat('  PROVIDE '+target_info.Cprefix+'_tls_index');
+            Concat('  LONG 0');
             Concat('  SYMBOL edata');
             Concat('  SYMBOL __data_end__');
             Concat('ENDEXESECTION');
@@ -1019,6 +1033,34 @@ implementation
             Concat('  OBJSECTION .bss*');
             Concat('  SYMBOL __bss_end__');
             Concat('ENDEXESECTION');
+            Concat('EXESECTION .tls');
+            Concat('  SYMBOL ___tls_start__');
+            Concat('  OBJSECTION .tls*');
+            Concat('  SYMBOL ___tls_end__');
+            Concat('ENDEXESECTION');
+            Concat('EXESECTION .CRT');
+            Concat('  SYMBOL ___crt_xc_start__');
+            Concat('  OBJSECTION .CRT$XC*');{  /* C initialization */');}
+            Concat('  SYMBOL ___crt_xc_end__');
+            Concat('  SYMBOL ___crt_xi_start__');
+            Concat('  OBJSECTION .CRT$XI*');{  /* C++ initialization */');}
+            Concat('  SYMBOL ___crt_xi_end__');
+            Concat('  SYMBOL ___crt_xl_start__');
+            Concat('  OBJSECTION .CRT$XL*'); {  /* TLS callbacks */'); }
+            { In GNU ld, this is defined in the TLS Directory support code }
+            Concat('  PROVIDE ___crt_xl_end__');
+            { Add a nil pointer as last element }
+            Concat('  LONG 0');
+{$ifdef x86_64}
+            Concat('  LONG 0');
+{$endif x86_64}
+            Concat('  SYMBOL ___crt_xp_start__');
+            Concat('  OBJSECTION .CRT$XP*'); {  /* Pre-termination */');}
+            Concat('  SYMBOL ___crt_xp_end__');
+            Concat('  SYMBOL ___crt_xt_start__');
+            Concat('  OBJSECTION .CRT$XT*');{  /* Termination */');}
+            Concat('  SYMBOL ___crt_xt_end__');
+            Concat('ENDEXESECTION');
             Concat('EXESECTION .idata');
             Concat('  OBJSECTION .idata$2*');
             Concat('  OBJSECTION .idata$3*');
@@ -1225,9 +1267,23 @@ implementation
             Add('    *(.glue_7)');
             Add('    . = ALIGN(8);');
             Add('     ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;');
-            Add('			LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*));  LONG (0);');
+            Add('    LONG (-1);');
+{$ifdef x86_64}
+            Add('    LONG (-1);');
+{$endif x86_64}
+            Add('    *(.ctors); *(.ctor); *(SORT(.ctors.*));  LONG (0);');
+{$ifdef x86_64}
+            Add('    LONG (0);');
+{$endif x86_64}
             Add('     ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;');
-            Add('			LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*));  LONG (0);');
+            Add('    LONG (-1);');
+{$ifdef x86_64}
+            Add('    LONG (-1);');
+{$endif x86_64}
+            Add('    *(.dtors); *(.dtor); *(SORT(.dtors.*));  LONG (0);');
+{$ifdef x86_64}
+            Add('    LONG (0);');
+{$endif x86_64}
             Add('     *(.fini)');
             Add('    PROVIDE (etext = .);');
             Add('    *(.gcc_except_table)');
@@ -1239,6 +1295,8 @@ implementation
             Add('    *(.data2)');
             Add('    *(SORT(.data$*))');
             Add('    *(.jcr)');
+            Add('    PROVIDE ('+target_info.Cprefix+'_tls_index = .);');
+            Add('    LONG (0);');
             Add('    __data_end__ = . ;');
             Add('    *(.data_cygwin_nocopy)');
             Add('  }');
@@ -1286,6 +1344,7 @@ implementation
             Add('    ___crt_xl_start__ = . ;');
             Add('    *(SORT(.CRT$XL*))  /* TLS callbacks */');
             Add('    /* ___crt_xl_end__ is defined in the TLS Directory support code */');
+            Add('    PROVIDE (___crt_xl_end__ = .);');
             Add('    ___crt_xp_start__ = . ;');
             Add('    *(SORT(.CRT$XP*))  /* Pre-termination */');
             Add('    ___crt_xp_end__ = . ;');
@@ -1597,7 +1656,8 @@ implementation
              cmdstr:=cmdstr+' --version '+dllversion;
            cmdstr:=cmdstr+' --input '+maybequoted(fn);
            cmdstr:=cmdstr+' --stack '+tostr(stacksize);
-           DoExec(FindUtil(utilsprefix+'postw32'),cmdstr,false,false);
+           if target_info.system in [system_i386_win32, system_i386_wdosx] then
+             DoExec(FindUtil(utilsprefix+'postw32'),cmdstr,false,false);
            postprocessexecutable:=true;
            exit;
          end;
@@ -1738,7 +1798,7 @@ implementation
             ExtName:=current_module.dllscannerinputlist.NameOfIndex(i);
             if (ExtName=funcname) then
               begin
-                current_module.AddExternalImport(dllname,funcname,0,false,false);
+                current_module.AddExternalImport(dllname,funcname,funcname,0,false,false);
                 importfound:=true;
                 current_module.dllscannerinputlist.Delete(i);
                 exit;

+ 74 - 4
compiler/utils/Makefile

@@ -1,8 +1,8 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2010/09/29]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/06/20]
 #
 default: all
-MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 BSDs = freebsd netbsd openbsd darwin
 UNIXs = linux $(BSDs) solaris qnx haiku
 LIMIT83fs = go32v2 os2 emx watcom
@@ -264,6 +264,29 @@ ifeq ($(UNITSDIR),)
 UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+ifndef FPCFPMAKE
+ifdef CROSSCOMPILE
+ifeq ($(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR)))),)
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPCFPMAKE:=$(shell $(FPCPROG) -PB)
+ifeq ($(strip $(wildcard $(FPCFPMAKE))),)
+FPCFPMAKE:=$(firstword $(FPCPROG))
+endif
+else
+override FPCFPMAKE=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+FPCFPMAKE=$(strip $(wildcard $(addsuffix /compiler/ppc$(SRCEXEEXT),$(FPCDIR))))
+FPMAKE_SKIP_CONFIG=-n
+export FPCFPMAKE
+export FPMAKE_SKIP_CONFIG
+endif
+else
+FPCFPMAKE=$(FPC)
+endif
+endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_PROGRAMS+=fpc ppufiles ppudump ppumove fpcsubst mkarmins mkx86ins
 endif
@@ -375,6 +398,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override TARGET_PROGRAMS+=fpc ppufiles ppudump ppumove fpcsubst mkarmins mkx86ins
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override TARGET_PROGRAMS+=fpc ppufiles ppudump ppumove fpcsubst mkarmins mkx86ins
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override TARGET_PROGRAMS+=fpc ppufiles ppudump ppumove fpcsubst mkarmins mkx86ins
 endif
@@ -561,6 +587,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override CLEAN_UNITS+=ppu crc usubst
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override CLEAN_UNITS+=ppu crc usubst
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override CLEAN_UNITS+=ppu crc usubst
 endif
@@ -748,6 +777,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override COMPILER_UNITDIR+=..
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_UNITDIR+=..
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override COMPILER_UNITDIR+=..
 endif
@@ -934,6 +966,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 override COMPILER_SOURCEDIR+=..
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+override COMPILER_SOURCEDIR+=..
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 override COMPILER_SOURCEDIR+=..
 endif
@@ -1357,6 +1392,11 @@ ifeq ($(OS_TARGET),NativeNT)
 SHAREDLIBEXT=.dll
 SHORTSUFFIX=nativent
 endif
+ifeq ($(OS_TARGET),wii)
+EXEEXT=.dol
+SHAREDLIBEXT=.so
+SHORTSUFFIX=wii
+endif
 else
 ifeq ($(OS_TARGET),go32v1)
 PPUEXT=.pp1
@@ -1893,6 +1933,9 @@ endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 REQUIRE_PACKAGES_RTL=1
 endif
+ifeq ($(FULL_TARGET),powerpc-wii)
+REQUIRE_PACKAGES_RTL=1
+endif
 ifeq ($(FULL_TARGET),sparc-linux)
 REQUIRE_PACKAGES_RTL=1
 endif
@@ -1976,6 +2019,15 @@ UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
 else
 UNITDIR_RTL=$(PACKAGEDIR_RTL)
 endif
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)/units/$(SOURCESUFFIX)
+else
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units_bs/$(SOURCESUFFIX)),)
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)/units_bs/$(SOURCESUFFIX)
+else
+UNITDIR_FPMAKE_RTL=$(PACKAGEDIR_RTL)
+endif
+endif
 ifdef CHECKDEPEND
 $(PACKAGEDIR_RTL)/$(OS_TARGET)/$(FPCMADE):
 	$(MAKE) -C $(PACKAGEDIR_RTL)/$(OS_TARGET) $(FPCMADE)
@@ -1993,6 +2045,9 @@ endif
 ifdef UNITDIR_RTL
 override COMPILER_UNITDIR+=$(UNITDIR_RTL)
 endif
+ifdef UNITDIR_FPMAKE_RTL
+override COMPILER_FPMAKE_UNITDIR+=$(UNITDIR_FPMAKE_RTL)
+endif
 endif
 ifndef NOCPUDEF
 override FPCOPTDEF=$(ARCH)
@@ -2404,6 +2459,7 @@ fpc_baseinfo:
 	@$(ECHO)  Full Target.. $(FULL_TARGET)
 	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
 	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)  FPC fpmake... $(FPCFPMAKE)
 	@$(ECHO)
 	@$(ECHO)  == Directory info ==
 	@$(ECHO)
@@ -2525,11 +2581,25 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 endif
 .NOTPARALLEL:
-ppu$(PPUEXT): ppu.pas
+ifndef NOCPUDEF
+ppu$(PPUEXT): ../ppu.pas
+	$(MAKE) ppu$(PPUEXT) NOCPUDEF=1
+ppudump$(EXEEXT): ppudump.pp ppu$(PPUEXT)
+	$(MAKE) ppudump$(EXEEXT) NOCPUDEF=1
 ppufiles$(EXEEXT): ppufiles.pp ppu$(PPUEXT)
+	$(MAKE) ppufiles$(EXEEXT) NOCPUDEF=1
+ppumove$(EXEEXT): ppumove.pp ppu$(PPUEXT)
+	$(MAKE) ppumove$(EXEEXT) NOCPUDEF=1
+else
+ppu$(PPUEXT): ../ppu.pas
+	$(COMPILER) ../ppu.pas -Fu../generic -dGENERIC_CPU -Fi..
 ppudump$(EXEEXT): ppudump.pp ppu$(PPUEXT)
-	$(COMPILER) ppudump.pp -Fu../$(CPU_TARGET) -Fi..
+	$(COMPILER) ppudump.pp -Fu../generic -dGENERIC_CPU -Fi..
+ppufiles$(EXEEXT): ppufiles.pp ppu$(PPUEXT)
+	$(COMPILER) ppufiles.pp -Fu../generic -dGENERIC_CPU -Fi..
 ppumove$(EXEEXT): ppumove.pp ppu$(PPUEXT)
+	$(COMPILER) ppumove.pp -Fu../generic -dGENERIC_CPU -Fi..
+endif
 msg2inc$(EXEEXT): $(COMPILER_UNITTARGETDIR) msg2inc.pp
 fpcsubst$(EXEEXT): fpcsubst.pp usubst.pp
 fpcmkcfg$(EXEEXT): fpcmkcfg.pp usubst.pp fpccfg.inc fpcfg.inc fpini.inc

+ 20 - 2
compiler/utils/Makefile.fpc

@@ -34,15 +34,33 @@ build=n
 # due to overwriting each other's link.res file
 .NOTPARALLEL:
 
-ppu$(PPUEXT): ppu.pas
+ifndef NOCPUDEF
+ppu$(PPUEXT): ../ppu.pas
+	$(MAKE) ppu$(PPUEXT) NOCPUDEF=1
+
+ppudump$(EXEEXT): ppudump.pp ppu$(PPUEXT)
+	$(MAKE) ppudump$(EXEEXT) NOCPUDEF=1
 
 ppufiles$(EXEEXT): ppufiles.pp ppu$(PPUEXT)
+	$(MAKE) ppufiles$(EXEEXT) NOCPUDEF=1
+
+ppumove$(EXEEXT): ppumove.pp ppu$(PPUEXT)
+	$(MAKE) ppumove$(EXEEXT) NOCPUDEF=1
 
+else
+ppu$(PPUEXT): ../ppu.pas
+        $(COMPILER) ../ppu.pas -Fu../generic -dGENERIC_CPU -Fi..
 
 ppudump$(EXEEXT): ppudump.pp ppu$(PPUEXT)
-        $(COMPILER) ppudump.pp -Fu../$(CPU_TARGET) -Fi..
+        $(COMPILER) ppudump.pp -Fu../generic -dGENERIC_CPU -Fi..
+
+ppufiles$(EXEEXT): ppufiles.pp ppu$(PPUEXT)
+        $(COMPILER) ppufiles.pp -Fu../generic -dGENERIC_CPU -Fi..
 
 ppumove$(EXEEXT): ppumove.pp ppu$(PPUEXT)
+        $(COMPILER) ppumove.pp -Fu../generic -dGENERIC_CPU -Fi..
+
+endif
 
 msg2inc$(EXEEXT): $(COMPILER_UNITTARGETDIR) msg2inc.pp
 

+ 18 - 0
compiler/utils/gppc386.pp

@@ -44,12 +44,14 @@ uses
 const
 {$ifdef Unix}
   GDBExeName : String = 'gdbpas';
+  GDBAltExeName = 'gdb';
   GDBIniName = '.gdbinit';
   DefaultCompilerName = 'ppc386';
   PathSep=':';
   DirSep = '/';
 {$else}
   GDBExeName : String = 'gdbpas.exe';
+  GDBAltExeName = 'gdb.exe';
   GDBIniName = 'gdb.ini';
   DefaultCompilerName = 'ppc386.exe';
   PathSep=';';
@@ -62,6 +64,17 @@ const
   FpcGDBIniName = 'gdb.fpc';
   GDBIniTempName : string = 'gdb4fpc.ini';
 
+
+{ Dos/Windows GDB still need forward slashes }
+procedure AdaptToGDB(var filename : string);
+var
+  i : longint;
+begin
+  for i:=1 to length(filename) do
+    if filename[i]='\' then
+      filename[i]:='/';
+end;
+
 var
    fpcgdbini : text;
    CompilerName,Dir,Name,Ext : String;
@@ -144,6 +157,11 @@ begin
   {$endif}
 
   GDBExeName:=fsearch(GDBExeName,Dir+PathSep+GetEnv('PATH'));
+  if GDBExeName='' then
+    GDBExeName:=fsearch(GDBAltExeName,Dir+PathSep+GetEnv('PATH'));
+
+  AdaptToGDB(CompilerName);
+  AdaptToGDB(GDBIniTempName);
   {$ifdef EXTDEBUG}
   Writeln(stderr,'Starting ',GDBExeName,
 {$ifdef win32}

+ 31 - 35
compiler/utils/mkx86reg.pp

@@ -321,10 +321,7 @@ begin
   openinc(stdfile,fileprefix+'std.inc');
   openinc(attfile,fileprefix+'att.inc');
   openinc(intfile,fileprefix+'int.inc');
-  if not(x86_64) then
-    begin
-      openinc(nasmfile,fileprefix+'nasm.inc');
-    end;
+  openinc(nasmfile,fileprefix+'nasm.inc');
   openinc(stabfile,fileprefix+'stab.inc');
   openinc(dwrffile,fileprefix+'dwrf.inc');
   openinc(otfile,fileprefix+'ot.inc');
@@ -334,10 +331,7 @@ begin
   openinc(srifile,fileprefix+'sri.inc');
   openinc(arifile,fileprefix+'ari.inc');
   openinc(irifile,fileprefix+'iri.inc');
-  if not(x86_64) then
-    begin
-      openinc(nrifile,fileprefix+'nri.inc');
-    end;
+  openinc(nrifile,fileprefix+'nri.inc');
   first:=true;
   for i:=0 to regcount-1 do
     begin
@@ -347,10 +341,7 @@ begin
           writeln(stdfile,',');
           writeln(attfile,',');
           writeln(intfile,',');
-          if not(x86_64) then
-            begin
-              writeln(nasmfile,',');
-            end;
+          writeln(nasmfile,',');
           writeln(stabfile,',');
           writeln(dwrffile,',');
           writeln(otfile,',');
@@ -359,10 +350,7 @@ begin
           writeln(srifile,',');
           writeln(arifile,',');
           writeln(irifile,',');
-          if not(x86_64) then
-            begin
-              writeln(nrifile,',');
-            end;
+          writeln(nrifile,',');
         end
       else
         first:=false;
@@ -371,10 +359,7 @@ begin
       write(stdfile,'''',stdnames[i],'''');
       write(attfile,'''',attnames[i],'''');
       write(intfile,'''',intnames[i],'''');
-      if not(x86_64) then
-        begin
-          write(nasmfile,'''',nasmnames[i],'''');
-        end;
+      write(nasmfile,'''',nasmnames[i],'''');
       { stabs uses the same register numbering as dwarf
         for x86_64 CPU }
       if x86_64 then
@@ -391,10 +376,7 @@ begin
       write(srifile,std_regname_index[i]);
       write(arifile,att_regname_index[i]);
       write(irifile,int_regname_index[i]);
-      if not(x86_64) then
-        begin
-          write(nrifile,nasm_regname_index[i]);
-        end;
+      write(nrifile,nasm_regname_index[i]);
     end;
   write(norfile,regcount);
   close(confile);
@@ -402,10 +384,7 @@ begin
   closeinc(attfile);
   closeinc(stdfile);
   closeinc(intfile);
-  if not(x86_64) then
-    begin
-      closeinc(nasmfile);
-    end;
+  closeinc(nasmfile);
   closeinc(stabfile);
   closeinc(dwrffile);
   closeinc(otfile);
@@ -415,10 +394,7 @@ begin
   closeinc(srifile);
   closeinc(arifile);
   closeinc(irifile);
-  if not(x86_64) then
-    begin
-      closeinc(nrifile);
-    end;
+  closeinc(nrifile);
   writeln('Done!');
   writeln(regcount,' registers procesed');
 end;
@@ -426,11 +402,31 @@ end;
 
 begin
    writeln('Register Table Converter Version ',Version);
-   x86_64:=paramstr(1)='x86_64';
+   if paramcount=0 then
+     begin
+       x86_64:=false;
+     end
+   else
+     begin
+       x86_64:=paramstr(1)='x86_64';
+       if (paramcount<>1) or
+          ((paramstr(1)<>'i386') and (paramstr(1)<>'x86_64')) then
+         begin
+           writeln('Usage: ',paramstr(0));
+           writeln('Only one optional parameter is allowed: i386 or x86_64');
+           halt(1);
+         end;
+     end;
    if x86_64 then
-     fileprefix:='r8664'
+     begin
+       fileprefix:='r8664';
+       writeln('Processing for CPU x86_64');
+     end
    else
-     fileprefix:='r386';
+     begin
+       fileprefix:='r386';
+       writeln('Processing for CPU i386');
+     end;
    line:=0;
    regcount:=0;
    read_x86reg_file;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 206 - 463
compiler/utils/ppudump.pp


+ 41 - 2
compiler/verbose.pas

@@ -80,6 +80,11 @@ interface
     procedure PrepareReport;
 
     function  CheckVerbosity(v:longint):boolean;
+    function  SetMessageVerbosity(v:longint;state:tmsgstate):boolean;
+    procedure RestoreLocalVerbosity(pstate : pmessagestaterecord);
+    procedure FreeLocalVerbosity(var fstate : pmessagestaterecord);
+
+    function ChangeMessageVerbosity(s: string; var i: integer;state:tmsgstate): boolean;
     procedure ShowStatus;
     function  ErrorCount:longint;
     procedure SetErrorFlags(const s:string);
@@ -176,8 +181,29 @@ implementation
          writeln(status.reportbugfile,'FPC bug report file');
       end;
 
+    procedure RestoreLocalVerbosity(pstate : pmessagestaterecord);
+      begin
+        msg^.ResetStates;
+        while assigned(pstate) do
+          begin
+            SetMessageVerbosity(pstate^.value,pstate^.state);
+            pstate:=pstate^.next;
+          end;
+      end;
 
-    function ClearMessageVerbosity(s: string; var i: integer): boolean;
+    procedure FreeLocalVerbosity(var fstate : pmessagestaterecord);
+    var pstate : pmessagestaterecord;
+      begin
+        pstate:=fstate;
+        while assigned(pstate) do
+          begin
+            fstate:=pstate^.next;
+            freemem(pstate);
+            pstate:=fstate;
+          end;
+      end;
+
+    function ChangeMessageVerbosity(s: string; var i: integer;state:tmsgstate): boolean;
       var
         tok  : string;
         code : longint;
@@ -195,12 +221,23 @@ implementation
           val(tok, msgnr, code);
           if (code<>0) then
             exit;
-          if not msg^.clearverbosity(msgnr) then
+          if not msg^.setverbosity(msgnr,state) then
             exit;
         until false;
         result:=true;
       end;
 
+    { This function is only used for command line argument -vmXXX }
+    { thus the message needs to be cleared globally }
+    function ClearMessageVerbosity(s: string; var i: integer): boolean;
+      begin
+        ClearMessageVerbosity:=ChangeMessageVerbosity(s,i,ms_off_global);
+      end;
+
+    function SetMessageVerbosity(v:longint;state:tmsgstate):boolean;
+      begin
+        result:=msg^.setverbosity(v,state);
+      end;
 
     function CheckVerbosity(v:longint):boolean;
       begin
@@ -592,6 +629,8 @@ implementation
                       st:=ms_error
                     else
                       st:=GetMessageState(w);
+                    { We only want to know about local value }
+                    st:= tmsgstate(ord(st) and ms_local_mask);
                     if st=ms_error then
                       begin
                         v:=v or V_Error;

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio