04-pe-sections.sh (1112B)
1 # Golden: objdump -h on a linked PE32+ executable. PE images now open 2 # through kit_obj_open, so -h flows through the neutral dump_sections path 3 # (the same "Sections:" header as ELF / Mach-O / COFF .obj), with .text and 4 # .idata present. Gated on llvm-mingw UCRT availability. 5 6 find_sdk() { 7 local d 8 for d in \ 9 /tmp/llvm-mingw*/llvm-mingw-*-ucrt-*/x86_64-w64-mingw32 \ 10 /tmp/llvm-mingw*/x86_64-w64-mingw32 \ 11 /private/tmp/llvm-mingw*/llvm-mingw-*-ucrt-*/x86_64-w64-mingw32 \ 12 /private/tmp/llvm-mingw*/x86_64-w64-mingw32; do 13 if [ -d "$d/lib" ] && [ -r "$d/include/windows.h" ]; then 14 printf '%s\n' "$d" 15 return 0 16 fi 17 done 18 return 1 19 } 20 21 SDK=$(find_sdk) || { 22 echo "SKIP: no llvm-mingw UCRT sysroot" 23 exit 0 24 } 25 26 cat > t.c <<'EOF' 27 int main(void) { return 0; } 28 EOF 29 "$KIT" cc -target x86_64-windows --sysroot "$SDK" t.c -o t.exe 30 "$KIT" objdump -h t.exe | awk ' 31 /^Sections:/ {print "found: PE sections"; next} 32 /^Idx Name.*Size.*Align.*Flags/ {print "found: PE header row"; next} 33 /^ *[0-9]+ \.text/ {print "section: .text"; next} 34 /^ *[0-9]+ \.idata/ {print "section: .idata"; next}'