Hello,

I have pushed a small Windows-focused patch series.  The goal is
to improve a few robustness issues without changing default x86/x64 output
behavior.

The series contains four independent changes:

  1. win32: make compile lock initialization thread-safe

     libtcc serializes compilation because parser/codegen state is still
     global.  On Windows the CRITICAL_SECTION used for this lock was lazily
     initialized without synchronization, so two first-time callers could race.
     The patch uses interlocked state transitions around 
InitializeCriticalSection.

  2. win32: run cv2pdb without shell quoting issues

     -g.pdb used system("cv2pdb.exe ...") with a fixed-size command buffer.
     That breaks for output paths containing spaces and unnecessarily goes
     through the shell.  The patch uses _spawnvp on Windows, keeps a quoted
     fallback for non-Windows PE cross builds, and allocates the PDB path
     based on the actual output name.

  3. pe: add dll characteristic linker options

     This adds PE linker options for dynamicbase, nxcompat, high-entropy-va,
     and tsaware, plus no-/disable- forms.  high-entropy-va is available for
     x86_64 and ARM64 PE targets and implies dynamicbase. Disabling
     dynamicbase also clears high-entropy-va.  When dynamicbase is enabled for
     an executable, TCC enables base relocation emission and clears the
     RELOCS_STRIPPED file characteristic.  ARM64 keeps its existing default
     hardening flags. x86/x64 defaults are not changed.

  4. win32: improve tccrun protection diagnostics

     The -run memory protection path now reports VirtualProtect failures on
     Windows instead of the Unix mprotect message.  On x64 it also checks
     RtlAddFunctionTable so unwind registration failures are not silent.

I tested the series on Windows x86_64 with:

  ./configure --cc=gcc
  make -j2
  make test

The full test target passed.  I also checked generated PE headers with
objdump for the default case, dynamicbase/nxcompat, high-entropy-va,
no-dynamicbase, and the high-entropy-va/no-dynamicbase ordering cases, and
verified the produced executables run.  For the inverse path, I verified that
no-dynamicbase executables keep RELOCS_STRIPPED set and don't get a .reloc
section.

Regards,

Mounir IDRASSI



_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to