NO

Author Topic: Include .reloc section in normal .exe PE  (Read 6965 times)

shaka

  • Guest
Include .reloc section in normal .exe PE
« on: July 10, 2009, 09:32:06 PM »
Hello to everybody! This is my first post :)
I wanted to ask something...

How can i create a normal PE executable file with the .reloc section included? (I assume the linker strips it out if the file is not a dll).
I was some time wandering through various linkers and coundn't get it... some help would be really appreciated

Thanks in advance ^^


**edit: i found that turbo linker does not strip relocation info from normal pe executables, so i could use it as linker. Anyway, it would be nice to know it this can be done with pelles because it's my favourite suite :)
« Last Edit: July 11, 2009, 01:29:05 AM by shaka »

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Include .reloc section in normal .exe PE
« Reply #1 on: July 11, 2009, 09:34:21 AM »
Hi shaka,

Welcome to the forum.

It's easy to add a relocation to a PE file. All you need to do is to specify the /FIXED:NO linker switch :

In Pelles IDE, follow the path Project -> Options -> Macros and edit LINKFLAGS :

Code: [Select]
-subsystem:windows -machine:x86  -fixed:no kernel32.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib advapi32.lib delayimp.lib
Attached is a quick example built with the relocation section.

Code: [Select]
podump.exe /HEADERS Window.exe
Code: [Select]
SECTION #4
  .reloc name
     20C virtual size
    5000 virtual address (00405000 to 0040520B)
     400 size of raw data
    2600 offset to raw data
       0 offset to relocation table
       0 offset to line numbers
       0 number of relocations
       0 number of line numbers
42000040 characteristics:
           Initialized data
           Memory discardable
           Memory read

SUMMARY
    1000 .data
    1000 .rdata
    1000 .reloc
    2000 .text

You cannot use directly tlink.exe with Pelles tools as it does not support the MS COFF format used by Pelles development suit.

To convert between MS COFF and OMF, you need a tool like Agner Fog's Object file converter
Code it... That's all...

shaka

  • Guest
Re: Include .reloc section in normal .exe PE
« Reply #2 on: July 12, 2009, 12:05:18 AM »
Thank you Vortex, that really helped me a lot.

This is a nice forum (: