[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/30141] New: LD does not mark INIT section as IMAGE_SCN_MEM_DISCA
From: |
pali at kernel dot org |
Subject: |
[Bug ld/30141] New: LD does not mark INIT section as IMAGE_SCN_MEM_DISCARDABLE |
Date: |
Sun, 19 Feb 2023 15:46:55 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=30141
Bug ID: 30141
Summary: LD does not mark INIT section as
IMAGE_SCN_MEM_DISCARDABLE
Product: binutils
Version: 2.39
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: pali at kernel dot org
Target Milestone: ---
INIT code section is used in NT drivers (Native PE binaries) only during
initilization and section should be marked as discardable to not waste memory.
LD does not mark this section as discardable.
Test case: Very simple NT kernel driver with entry point which does nothing:
$ cat test-init.c
__attribute__((stdcall))
long DriverEntry(void *DriverObject, void *RegistryPath) asm("DriverEntry")
__attribute__((section("INIT")));
__attribute__((stdcall))
long DriverEntry(void *DriverObject, void *RegistryPath) {
return 0;
}
$ x86_64-w64-mingw32-gcc -nostartfiles -nodefaultlibs -nostdlib
-Wl,--subsystem,native -e DriverEntry test-init.c -o test-init.sys
$ readpe test-init.sys | grep -A 11 'Name:\s*INIT'
export directory not found
Name: INIT
Virtual Address: 0x2000
Physical Address: 0x14
Size: 0x200 (512 bytes)
Pointer To Data: 0x600
Relocations: 0
Characteristics: 0x60300020
Characteristic Names
IMAGE_SCN_CNT_CODE
IMAGE_SCN_MEM_EXECUTE
IMAGE_SCN_MEM_READ
Section
As can be seen in readpe output, INIT section is not marked as discardable
(IMAGE_SCN_MEM_DISCARDABLE). I'm not sure how to verify this with objdump as I
do not know how it shows IMAGE_SCN_* flags. So I used readpe for verification.
For NT kernel drivers same applies for .idata and .rsrc sections which should
be discardable too.
--
You are receiving this mail because:
You are on the CC list for the bug.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug ld/30141] New: LD does not mark INIT section as IMAGE_SCN_MEM_DISCARDABLE,
pali at kernel dot org <=