Alexandre Julliard : winegcc: Also check magic number to detect shared libraries.

Alexandre Julliard julliard at winehq.org
Mon Nov 4 16:40:25 CST 2019


Module: wine
Branch: master
Commit: 21c832da633096dfed47c7865c8912420f127ae8
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=21c832da633096dfed47c7865c8912420f127ae8

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Nov  4 15:54:58 2019 +0100

winegcc: Also check magic number to detect shared libraries.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/winegcc/utils.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/winegcc/utils.c b/tools/winegcc/utils.c
index 3197e46e47..52f46c491b 100644
--- a/tools/winegcc/utils.c
+++ b/tools/winegcc/utils.c
@@ -212,6 +212,7 @@ file_type get_file_type(const char* filename)
 {
     /* see tools/winebuild/res32.c: check_header for details */
     static const char res_sig[] = { 0,0,0,0, 32,0,0,0, 0xff,0xff, 0,0, 0xff,0xff, 0,0, 0,0,0,0, 0,0, 0,0, 0,0,0,0, 0,0,0,0 };
+    static const char elf_sig[4] = "\177ELF";
     char buf[sizeof(res_sig)];
     int fd, cnt;
 
@@ -230,6 +231,11 @@ file_type get_file_type(const char* filename)
     if (strendswith(filename, ".def")) return file_def;
     if (strendswith(filename, ".spec")) return file_spec;
     if (strendswith(filename, ".rc")) return file_rc;
+    if (cnt >= sizeof(elf_sig) && !memcmp(buf, elf_sig, sizeof(elf_sig))) return file_so;  /* ELF lib */
+    if (cnt >= sizeof(unsigned int) &&
+        (*(unsigned int *)buf == 0xfeedface || *(unsigned int *)buf == 0xcefaedfe ||
+         *(unsigned int *)buf == 0xfeedfacf || *(unsigned int *)buf == 0xcffaedfe))
+        return file_so; /* Mach-O lib */
 
     return file_other;
 }




More information about the wine-cvs mailing list