4

I've used this as a reference, but it doesn't appear to be complete. When I set /NODEFAULTLIB, I get linker errors about missing __except_list, __load_config_used, and a few other things apparently related to SEH. It's easy enough to get _CxxThrowException and friends linked correctly, but I have no idea what __except_list is supposed to be and I don't know where to start looking.

I'm using both MSC and IC. When using IC, the linker reports __except_list as missing, though this is not the case with MSC.

For those of you who's favorite answer is "why?": It's because I want to know how this works, and I'm tired of do-nothing test applications starting life with 300kb committed for absolutely no reason.

defube
  • 2,395
  • 1
  • 22
  • 34
  • Well, the "do nothing" application with 300kb has 300kb because the compiler doesn't care that it doesn't do anything. Real applications do something, and sometimes it's just not worth playing magic to prevent basic core features being added into "do nothing" apps. Yes, it's not an answer, which is why I clicked on 'add comment' :-) – Christian Stieber Aug 18 '12 at 10:17
  • A compiler inevitably takes a dependency on its CRT implementation. Especially so for exception handling, it is a heavy implementation detail and every vendor does it differently. Write C to have a better shot at it. Whatever you end up with will have a dependency on a CRT and on an operating system. You stop worrying about 300 KB CRT code when you got a gigabyte of OS code too by using a shared version of the CRT. So it is shared, just as the OS code is shared. Both compilers you use support that. – Hans Passant Aug 18 '12 at 10:46
  • 1
    I know. As this is part of a personal project, I mainly wanted as much control over the entire lifetime of my program without having to write an operating system. – defube Aug 20 '12 at 04:43

2 Answers2

2

If you want to get rid of CRT dependency, then pass /Zl option to the compiler. Linker does not need any special options (compiler won't insert /DEFAULTLIB:... into .drectve section, so linker won't bind your EXE to any CRT). Of course you shouldn't be using C++ exceptions or heap in your code; or you need to provide your own version of library functions written in assembly language.

Coding Mash
  • 3,338
  • 5
  • 24
  • 45
Mikhail Kupchik
  • 308
  • 2
  • 8
0

linker option /safeseh:no (look at IMAGE_LOAD_CONFIG_DIRECTORY in PE image info).

phil
  • 1