selfrando icon indicating copy to clipboard operation
selfrando copied to clipboard

Detect when building a Windows program without Trapped libraries

Open ahomescu opened this issue 8 years ago • 0 comments

Before building a Windows program with selfrando, we need to add TRaP information to all MSVC libraries, which the trap-msvc-libs.py script does. We currently rely on the developer having done this beforehand. If they do not, the program just builds and then silently crashes.

As an enhancement, it would be really useful for TrapLinker/LinkWrapper on Windows to detect if any imported system libraries are missing TRaP info, and abort linking if so. This is not trivial to implement, and would mean that LinkWrapper would need to do the following:

  1. For each input object file or static library, LinkWrapper would need to build a list of all /DEFAULTLIB libraries used by the object or library. These are stored in the .drectve section which contains all linker directives. Additionally, there may be more default libraries on the linker command line.

2a. After building a full list of these libraries, LinkWrapper would need to check that all of them can be found in TrappedMSVCLibs, assuming that all libraries there contain TRaP information and that this directory is at the front of the linker's library search path (usually in the LIB environment variable).

2b. Alternatively, LinkWrapper could take a more thorough approach that replicates the linker's library resolution process: LinkWrapper could try to locate each system library using the LIB environment variable (a list of library directories separated by semicolons), then read in that library and check if it contains TRaP information.

ahomescu avatar Feb 11 '17 00:02 ahomescu