From patchwork Sat Dec 17 16:51:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62087 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DD0633AA9428 for ; Sat, 17 Dec 2022 16:52:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD0633AA9428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671295971; bh=LciV2STUvZjLO6Uj4CyuxLJVkd/FWwEsJ8DMc9fm4e8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=a6VN9DibmkCPqUWXTM00gRztOznzxP/tC88QusxIAk7mNaFC+lqGXNBp0csu/h5bY v5tT4i0JSYgVwFA+4APH5ZCT/913a+LeZ/ra8FJchWP4XLVgGIYKjDQelInruay/eE mKdvNcaV7NrrHipdRA1oozsUOQk9wsubVVLrDGbU= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id ECE3A3AA942E for ; Sat, 17 Dec 2022 16:52:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECE3A3AA942E Received: by mail-pl1-x633.google.com with SMTP id l10so5187597plb.8 for ; Sat, 17 Dec 2022 08:52:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LciV2STUvZjLO6Uj4CyuxLJVkd/FWwEsJ8DMc9fm4e8=; b=d1WYsfWr7w87CyxXowp83xQP95KoLJtlXRGwMChGQj0QLikxNLerPvtucZFZpCz/7E z6Z5Fcu4KM4Q1N65taZ/frG3U50uCvvTLm4nq2e4TR+yk/YzSnFVXz6CwHK8xqq73cpk cwBBuZxAdL+XOy+rDf08f9qfrpO0zx8iFR8D5gI6+GE6vW00OWvG0cyz9D+adicgwmtx 7592VSS8vYo2be1btMLT0u56B63kztMFVaUdphm6Ogn0gXuguCgjj7eMFL69DkLaHKc/ OCKej3tM+HDo3sDAmEWFEQG8Q6SUDsplpglq445riOJraLb543vOdDkdbiFRd4vg04H9 eJNw== X-Gm-Message-State: ANoB5pnOUTe2gpBLtIvZSv4bv5fS4PCqWClhoORprjT6zm1T2xJhA0kq ycczKWN2rxYaWkeMhdyXJsi3kA16i/s= X-Google-Smtp-Source: AA0mqf5uBhvO8bF4WcpuR3iZojd8uIYltYbdHXks36PTgmKJwM+M0xz5wIhNAJiVbAgB5SffURLNgQ== X-Received: by 2002:a17:90b:3687:b0:21a:1793:5c99 with SMTP id mj7-20020a17090b368700b0021a17935c99mr37272213pjb.42.1671295955735; Sat, 17 Dec 2022 08:52:35 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:35 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 01/16] ignore build directory Date: Sun, 18 Dec 2022 00:51:58 +0800 Message-Id: <20221217165213.152-2-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" This is for in in three building and won't affect IDE for example mkdir build && cd build && ../configure && make install Signed-off-by: Yonggang Luo --- .gitignore | 1 + ChangeLog | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 8bcd88d7..ca06dddd 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ Makefile.in /INSTALL /aclocal.m4 /autom4te.* +/build /config.cache /config.h /config.h.in diff --git a/ChangeLog b/ChangeLog index 52efca04..35a37343 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2022-12-17 Yonggang Luo + + * .gitignore: Ignore build directory + 2022-11-02 Mark Wielaard * configure.ac (AC_INIT): Set version to 0.188. From patchwork Sat Dec 17 16:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62088 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2FFA03AA9434 for ; Sat, 17 Dec 2022 16:53:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FFA03AA9434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671295983; bh=TD5MdP0MU+ry7acB/LFG2Sj6RuLS9yDRrAS4Bcadpmc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=lYQluK0MR/yEZMKIOLTZkY0kCH+Yo+WxOD2+ggpXf2S0P+v68paU8t0u9dK4QYXtX 7WzXHBN1ocg68cuFqOn0XA+UkpC468B0jkZGLxu/h74dKTfPacxQt86/q48+Z56+53 zUHKZv7s9erwcE9gISAJWHmuqz7vNpyDzYcjZNlY= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id C7CEB3AA88AB for ; Sat, 17 Dec 2022 16:52:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7CEB3AA88AB Received: by mail-pl1-x62f.google.com with SMTP id w23so5161801ply.12 for ; Sat, 17 Dec 2022 08:52:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TD5MdP0MU+ry7acB/LFG2Sj6RuLS9yDRrAS4Bcadpmc=; b=2CaOf1NAqjWIyHL67i6iGL28MRuS+rP/2mm+252kejGHgvhzoHrih2IE2RSfkYtK6J vAAMjhS68boRZOPU50ugDxifGz7MwPqAAAAONifEgdQi5zOi5C/CX+MxsliptkD859de g47ZB26yVYvorl39U2JqZ9B7y1iJDihSWxa8FuqbKlzvdK4q5Ut2s6hTHGVjoSzHdglG HZmWoQ4LCn5l+Zq/1uJJUTOxOwnJy5dJxa9Soa3sk2X/2oyNafLsAAagnvDqU5ZxvVD4 MHJDx9RMiPeuvAU/ZfA+VOjXGJAlF/KhMzrmKe2PqufiaYiPBjzUy+VEBeXPR7mzdJu+ jJ0w== X-Gm-Message-State: ANoB5pn8qsuT/LED2SfvzIpUSxw/6XZC8apbRYFt76dqMZAW1h5Nh5df 2iWv58cSSPVlzCdgwbJsnA4nKW0zIN4= X-Google-Smtp-Source: AA0mqf59ccTQW5w1S/hTJWyxwuO8fhw7XW4uSWiDgRsVwQZRzrYPiYYgjlKY/Cd1EnfgDhQbRo/S0w== X-Received: by 2002:a17:90a:3b0c:b0:219:1a4e:3490 with SMTP id d12-20020a17090a3b0c00b002191a4e3490mr37668460pjc.37.1671295957578; Sat, 17 Dec 2022 08:52:37 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:37 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 02/16] move platform depended include into system.h of libebl Date: Sun, 18 Dec 2022 00:51:59 +0800 Message-Id: <20221217165213.152-3-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Because all source in libebl #include , so #include in libeblP.h is enough, there is multiple memory-access.h file, so use relative path to include it properly, Signed-off-by: Yonggang Luo -#include -#include #include #include #include diff --git a/libebl/eblcorenote.c b/libebl/eblcorenote.c index 7fab3974..3d4c8a92 100644 --- a/libebl/eblcorenote.c +++ b/libebl/eblcorenote.c @@ -31,8 +31,6 @@ #endif #include -#include -#include #include #include #include diff --git a/libebl/ebldynamictagname.c b/libebl/ebldynamictagname.c index 5d4a3a58..7a430f49 100644 --- a/libebl/ebldynamictagname.c +++ b/libebl/ebldynamictagname.c @@ -34,7 +34,6 @@ #include #include #include -#include "system.h" const char * diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c index 5a7c5c62..0bb56c02 100644 --- a/libebl/eblobjnote.c +++ b/libebl/eblobjnote.c @@ -37,10 +37,10 @@ #include #include -#include "common.h" -#include "libelfP.h" -#include "libdwP.h" -#include "memory-access.h" +#include "../libelf/common.h" +#include "../libelf/libelfP.h" +#include "../libdw/libdwP.h" +#include "../libdw/memory-access.h" void diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c index 473a1f2f..2ee1b228 100644 --- a/libebl/eblobjnotetypename.c +++ b/libebl/eblobjnotetypename.c @@ -31,8 +31,6 @@ # include #endif -#include - #include #include #include diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c index 02f80653..6e884ea0 100644 --- a/libebl/eblopenbackend.c +++ b/libebl/eblopenbackend.c @@ -37,7 +37,6 @@ #include #include -#include #include Ebl *i386_init (Elf *, GElf_Half, Ebl *); diff --git a/libebl/libeblP.h b/libebl/libeblP.h index c408ed97..9dfd60de 100644 --- a/libebl/libeblP.h +++ b/libebl/libeblP.h @@ -33,6 +33,7 @@ #include #include +#include /* Backend handle. */ struct ebl From patchwork Sat Dec 17 16:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62089 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B7353AA981D for ; Sat, 17 Dec 2022 16:53:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B7353AA981D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671295994; bh=sIZLf7KyDHqTmjxXzDQOT9jd1kXcXrH1URbPuiptVrs=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=k2PhtE5jwRzeBKXy+6FtMMhcZ9iQLgHAwtJnmGXp4GYc2J2prG4yjWJoaffs78Tse B6X0IkpvAADLt9sgvdQRntaKyW+YLMQqypCiVVtFYLt4gw2gOWWpQ3t84hDHq8vc0C fPBBUmJK8XyXVCa3OiS1JoD/5QsuIkrvoRXo1Nrg= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id C84363AA88A1 for ; Sat, 17 Dec 2022 16:52:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C84363AA88A1 Received: by mail-pl1-x634.google.com with SMTP id l10so5187673plb.8 for ; Sat, 17 Dec 2022 08:52:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sIZLf7KyDHqTmjxXzDQOT9jd1kXcXrH1URbPuiptVrs=; b=S7u6mU56hQMdCvS1G2g3B6f1Mx0eWHf/IcdR/LipM/eW7A8ZfX7PMJ6+kshVApAFfH mVfEpWHUVIZtYtmBirkEDd0CKTS87Jroav8uq1SAcq/VaCxdGm+x9QKtNdyW7XZ5fTvz rQcAK3D4BNkQ7GPL8V8ihQ40DTX2QoZXeaoxVCiwPwM+WA2QNEdOqwnxc8r32i3n4/n7 iW6yRY+Ia78VKs/2woOkQAyXRhA+HHHSHBmSYcGKQAK8/xNDL6e6cyQGA/f7CR5I54Xl kIuiglwSqSIUGgOqjwUuiPAKTszTY3GuZA0bNjqXP3bhejeFhfzB5M37TbZJZv5NJuD0 Hj+g== X-Gm-Message-State: ANoB5pn1IryePLIpXBuavyJP7G2jceU8ycrFkGcE09MKBBapR40Jzvkk kqnP+FChMDbtjZ80LMK+/o6z3igl/To= X-Google-Smtp-Source: AA0mqf4fYvOwbf8Oasbn46xd7J/rFcHOH/sq3b2iimrjjOtVxLTZ6+ssGYNQI9NAcw4x+qQiJ0+tUA== X-Received: by 2002:a17:90a:3188:b0:219:3e5f:2a65 with SMTP id j8-20020a17090a318800b002193e5f2a65mr37872181pjb.36.1671295959429; Sat, 17 Dec 2022 08:52:39 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:38 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 03/16] Use configure to detect HAVE_DECL_MMAP and use it for system doesn't provide sys/mman.h Date: Sun, 18 Dec 2022 00:52:00 +0800 Message-Id: <20221217165213.152-4-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- configure.ac | 1 + lib/crc32_file.c | 4 ++-- lib/system.h | 2 ++ libelf/elf32_updatefile.c | 3 ++- libelf/elf_begin.c | 5 ++++- libelf/elf_end.c | 2 ++ libelf/elf_update.c | 5 ++++- 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 59be27ac..b84623fe 100644 --- a/configure.ac +++ b/configure.ac @@ -428,6 +428,7 @@ AC_CHECK_DECLS([memrchr, rawmemchr],[],[], [#define _GNU_SOURCE #include ]) AC_CHECK_DECLS([powerof2],[],[],[#include ]) +AC_CHECK_DECLS([mmap],[],[],[#include ]) AC_CHECK_DECLS([mempcpy],[],[], [#define _GNU_SOURCE #include ]) diff --git a/lib/crc32_file.c b/lib/crc32_file.c index f7607d0b..66833702 100644 --- a/lib/crc32_file.c +++ b/lib/crc32_file.c @@ -32,9 +32,7 @@ #include "libeu.h" #include -#include #include -#include #include "system.h" int @@ -45,6 +43,7 @@ crc32_file (int fd, uint32_t *resp) off_t off = 0; ssize_t count; +#if HAVE_DECL_MMAP struct stat st; if (fstat (fd, &st) == 0) { @@ -78,6 +77,7 @@ crc32_file (int fd, uint32_t *resp) munmap (mapped, mapsize); } } +#endif while ((count = TEMP_FAILURE_RETRY (pread (fd, buffer, sizeof buffer, off))) > 0) diff --git a/lib/system.h b/lib/system.h index bbbe06c4..561d3e03 100644 --- a/lib/system.h +++ b/lib/system.h @@ -42,7 +42,9 @@ /* System dependend headers */ #include #include +#if HAVE_DECL_MMAP #include +#endif #include #include diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index 46afa1f4..8229fd26 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -96,7 +96,7 @@ sort_sections (Elf_Scn **scns, Elf_ScnList *list) qsort (scns, scnp - scns, sizeof (*scns), compare_sections); } - +#if HAVE_DECL_MMAP static inline void fill_mmap (size_t offset, char *last_position, char *scn_start, char *const shdr_start, char *const shdr_end) @@ -482,6 +482,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) return 0; } +#endif /* Size of the buffer we use to generate the blocks of fill bytes. */ diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c index fe8c640a..6d31882e 100644 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -645,10 +645,12 @@ static struct Elf * read_file (int fildes, int64_t offset, size_t maxsize, Elf_Cmd cmd, Elf *parent) { +#if HAVE_DECL_MMAP void *map_address = NULL; int use_mmap = (cmd == ELF_C_READ_MMAP || cmd == ELF_C_RDWR_MMAP || cmd == ELF_C_WRITE_MMAP || cmd == ELF_C_READ_MMAP_PRIVATE); +#endif if (parent == NULL) { @@ -669,7 +671,7 @@ read_file (int fildes, int64_t offset, size_t maxsize, /* The parent is already loaded. Use it. */ assert (maxsize != ~((size_t) 0)); } - +#if HAVE_DECL_MMAP if (use_mmap) { if (parent == NULL) @@ -713,6 +715,7 @@ read_file (int fildes, int64_t offset, size_t maxsize, return result; } +#endif /* Otherwise we have to do it the hard way. We read as much as necessary from the file whenever we need information which is not available. */ diff --git a/libelf/elf_end.c b/libelf/elf_end.c index 5c451f36..8023b216 100644 --- a/libelf/elf_end.c +++ b/libelf/elf_end.c @@ -222,8 +222,10 @@ elf_end (Elf *elf) /* The file was read or mapped for this descriptor. */ if ((elf->flags & ELF_F_MALLOCED) != 0) free (elf->map_address); +#if HAVE_DECL_MMAP else if ((elf->flags & ELF_F_MMAPPED) != 0) munmap (elf->map_address, elf->maximum_size); +#endif } rwlock_unlock (elf->lock); diff --git a/libelf/elf_update.c b/libelf/elf_update.c index 56af3a1c..e81eb6c9 100644 --- a/libelf/elf_update.c +++ b/libelf/elf_update.c @@ -64,7 +64,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum) __libelf_seterrno (ELF_E_WRITE_ERROR); return -1; } - +#if HAVE_DECL_MMAP /* Try to map the file if this isn't done yet. */ if (elf->map_address == NULL && elf->cmd == ELF_C_WRITE_MMAP) { @@ -125,6 +125,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum) size = -1; } else +#endif { /* The file is not mmaped. */ if ((class == ELFCLASS32 @@ -145,6 +146,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum) size = -1; } +#if HAVE_DECL_MMAP /* POSIX says that ftruncate and write may clear the S_ISUID and S_ISGID mode bits. So make sure we restore them afterwards if they were set. This is not atomic if someone else chmod's the file while we operate. */ @@ -156,6 +158,7 @@ write_file (Elf *elf, int64_t size, int change_bo, size_t shnum) __libelf_seterrno (ELF_E_WRITE_ERROR); size = -1; } +#endif if (size != -1 && elf->parent == NULL) elf->maximum_size = size; From patchwork Sat Dec 17 16:52:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62090 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A2A93AA943B for ; Sat, 17 Dec 2022 16:53:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A2A93AA943B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296001; bh=gLfpHaD3znFkyL3WwbBCFWVo4BEeUYD/0GjAtdFnXuo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=otTv2nKuAgq/WBFtiRQMjyYJuh8bA+pedVkrFDz6CiwXEsyor4zmkPK16NkMVrN4l ugyyBz5F4dsSoo+9z/5e2VjThRSFXuKCCOoYOr8hu57piKP8IuH74HPog3k++Ova7v PnCTaP250hZGCSKsahZuHw9GrV/SIgQcGsD7oTGQ= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by sourceware.org (Postfix) with ESMTPS id 91CD23AA9422 for ; Sat, 17 Dec 2022 16:52:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 91CD23AA9422 Received: by mail-pj1-x1029.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so9059748pjr.3 for ; Sat, 17 Dec 2022 08:52:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gLfpHaD3znFkyL3WwbBCFWVo4BEeUYD/0GjAtdFnXuo=; b=7bXAqpNslkIydootqOfCDzVKrVEZEqD7DanXAdxhxwESC3K4smTvNwq+Br1LM1+MK3 e3DJqioD6/zkBB0OPmZCdRWWMXGV7z20HRZHfYgSR4orlLjmW4c7WQXe3kKs8SOFdkWl UQZPFQAuS3/lruZY5l92a2kDaPz5H6g5QJnF0sg5Vs2uAzFFFIeXYfgX9Lt9D7E/lwR8 SAHVU96fepwjQ8lvt1cg/XQk284mQroj51sKwmk8jJf37/nr39sBlAh2xCrtnBf2dtDg yiAhtp1e7lbVYwI6jjwmIvwPlFRp8qpMhLPupb48G0cRoGh1DPs4rjj0wFmvStoiPBIb d1Bg== X-Gm-Message-State: AFqh2kqbzV7duF0oB4N6bz/Ws9qX1bwTLYbrKLbEnKbOlQLxKZnhyOTG n7fqRw8/qMgSd0CKmXfz/X9eEWLqLAY= X-Google-Smtp-Source: AMrXdXug4z54XI9m1oDJM5CehHez7OrchNpYsTLfMI6QyMqrNGr5KKa7/cIhfWLoiCOp6+1HX3IPgQ== X-Received: by 2002:a17:90a:7e08:b0:223:7922:654d with SMTP id i8-20020a17090a7e0800b002237922654dmr9209569pjl.5.1671295961169; Sat, 17 Dec 2022 08:52:41 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:40 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 04/16] Fixes usage of basename about prototype differences Date: Sun, 18 Dec 2022 00:52:01 +0800 Message-Id: <20221217165213.152-5-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libdw/dwarf_getsrc_file.c | 2 +- libdwfl/dwfl_module_getsrc_file.c | 2 +- libdwfl/dwfl_segment_report_module.c | 2 +- libdwfl/find-debuginfo.c | 6 +++--- libdwfl/link_map.c | 2 +- src/addr2line.c | 4 ++-- src/nm.c | 4 ++-- src/stack.c | 2 +- src/strip.c | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libdw/dwarf_getsrc_file.c b/libdw/dwarf_getsrc_file.c index 5289c7da..884fea32 100644 --- a/libdw/dwarf_getsrc_file.c +++ b/libdw/dwarf_getsrc_file.c @@ -98,7 +98,7 @@ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column, /* Match the name with the name the user provided. */ const char *fname2 = line->files->info[lastfile].name; if (is_basename) - lastmatch = strcmp (basename (fname2), fname) == 0; + lastmatch = strcmp (basename ((char *)fname2), fname) == 0; else lastmatch = strcmp (fname2, fname) == 0; } diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c index cea2ba41..6daf29d6 100644 --- a/libdwfl/dwfl_module_getsrc_file.c +++ b/libdwfl/dwfl_module_getsrc_file.c @@ -103,7 +103,7 @@ dwfl_module_getsrc_file (Dwfl_Module *mod, { /* Match the name with the name the user provided. */ lastfile = file; - lastmatch = !strcmp (is_basename ? basename (file) : file, + lastmatch = !strcmp (is_basename ? basename ((char *)file) : file, fname); } } diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 19fa6ded..5342648a 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -719,7 +719,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, bias += fixup; if (module->name[0] != '\0') { - name = basename (module->name); + name = basename ((char *)module->name); name_is_final = true; } break; diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c index 7f7ab632..a9b7be3d 100644 --- a/libdwfl/find-debuginfo.c +++ b/libdwfl/find-debuginfo.c @@ -164,7 +164,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, { bool cancheck = debuglink_crc != (GElf_Word) 0; - const char *file_basename = file_name == NULL ? NULL : basename (file_name); + const char *file_basename = file_name == NULL ? NULL : basename ((char *)file_name); char *localname = NULL; /* We invent a debuglink .debug name if NULL, but then want to try the @@ -278,7 +278,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, else { subdir = NULL; - file = basename (debuglink_file); + file = basename ((char *)debuglink_file); } try_file_basename = debuglink_null; break; @@ -306,7 +306,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name, if (mod->dw != NULL && (p[0] == '\0' || p[0] == '/')) { fd = try_open (&main_stat, dir, ".dwz", - basename (file), &fname); + basename ((char *)file), &fname); if (fd < 0) { if (errno != ENOENT && errno != ENOTDIR) diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c index 7ec7eca1..403d4ee5 100644 --- a/libdwfl/link_map.c +++ b/libdwfl/link_map.c @@ -469,7 +469,7 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata, if (r_debug_info_module == NULL) { // XXX hook for sysroot - mod = __libdwfl_report_elf (dwfl, basename (name), + mod = __libdwfl_report_elf (dwfl, basename ((char *)name), name, fd, elf, base, true, true); if (mod != NULL) diff --git a/src/addr2line.c b/src/addr2line.c index 7768b266..3abf1d7a 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -381,7 +381,7 @@ print_dwarf_function (Dwfl_Module *mod, Dwarf_Addr addr) if (file == NULL) file = "???"; else if (only_basenames) - file = basename (file); + file = basename ((char *)file); else if (use_comp_dir && file[0] != '/') { const char *const *dirs; @@ -564,7 +564,7 @@ print_src (const char *src, int lineno, int linecol, Dwarf_Die *cu) const char *comp_dir_sep = ""; if (only_basenames) - src = basename (src); + src = basename ((char *)src); else if (use_comp_dir && src[0] != '/') { Dwarf_Attribute attr; diff --git a/src/nm.c b/src/nm.c index b46c1fd7..717ec0f6 100644 --- a/src/nm.c +++ b/src/nm.c @@ -1417,7 +1417,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr, int lineno; (void) dwarf_lineno (line, &lineno); const char *file = dwarf_linesrc (line, NULL, NULL); - file = (file != NULL) ? basename (file) : "???"; + file = (file != NULL) ? basename ((char *)file) : "???"; int n; n = obstack_printf (&whereob, "%s:%d%c", file, lineno, '\0'); @@ -1448,7 +1448,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr, { /* We found the line. */ int n = obstack_printf (&whereob, "%s:%" PRIu64 "%c", - basename ((*found)->file), + basename ((char *)(*found)->file), (*found)->lineno, '\0'); sym_mem[nentries_used].where = obstack_finish (&whereob); diff --git a/src/stack.c b/src/stack.c index 534aa93c..82413772 100644 --- a/src/stack.c +++ b/src/stack.c @@ -152,7 +152,7 @@ module_callback (Dwfl_Module *mod, void **userdata __attribute__((unused)), int width = get_addr_width (mod); printf ("0x%0*" PRIx64 "-0x%0*" PRIx64 " %s\n", - width, start, width, end, basename (name)); + width, start, width, end, basename ((char *)name)); const unsigned char *id; GElf_Addr id_vaddr; diff --git a/src/strip.c b/src/strip.c index 2a2cc801..6ac987fd 100644 --- a/src/strip.c +++ b/src/strip.c @@ -1800,7 +1800,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, elf_errmsg (-1)); } - char *debug_basename = basename (debug_fname_embed ?: debug_fname); + char *debug_basename = basename ((char *)(debug_fname_embed ?: debug_fname)); off_t crc_offset = strlen (debug_basename) + 1; /* Align to 4 byte boundary */ crc_offset = ((crc_offset - 1) & ~3) + 4; From patchwork Sat Dec 17 16:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62091 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB1D33AA9435 for ; Sat, 17 Dec 2022 16:53:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB1D33AA9435 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296013; bh=i9U5s6NQjGl/Zd1iCIVQKUJ0ZV5bXfCMr3i+nBCORC8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=yFMKUomBL295MndfE3eBKJjvB2GpfEYxnCZBfxNDlA89AVVy1nupMn4nF1MJJPquW GEMUlGwCIqANcMSw6hNeRAAKs+o3dCJTYaKEBNd7hlq1bYhpTX9nAstuXURKOTXmlI 6dmrr6N+kYgkkKn7kN/Hd7ocA3gIPYGPetiLTbtk= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 5B0353AA9426 for ; Sat, 17 Dec 2022 16:52:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B0353AA9426 Received: by mail-pj1-x1035.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so5231137pjj.4 for ; Sat, 17 Dec 2022 08:52:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i9U5s6NQjGl/Zd1iCIVQKUJ0ZV5bXfCMr3i+nBCORC8=; b=VwsbiZeKRXjgT3tsPlWZR828TeBi+O+u1hQo5lRzqg9+7I2dax9n7T0uMIV37dCF7x SSq6J8JjQLnT8XskYvyaN2AYewarP3aVVR5Zx4o+5bgz2V0josNvEMU/XvOC0Uu8NB3O aiRWYq4V5cVmY9rqhqRI97nENCebW47+DKMW4TzHQhxYF5KLo61x08Yva7yfV7GHoRUu lbuaOO380LjW0iDHBuAB9EBBrUAVTMWAlEBbGyYFsq5ZvajbEl/Nmvc/50Fnr/tC1ZUc KHgfSLqXOfoxDXirYxwo6436ZtnhIC+vdW7TzQyYueTxtwtO4LEDGAiHov7Mo5PEnrSf XB8w== X-Gm-Message-State: ANoB5pl1lGZa3MK5W77cIK/AhdPuhT/x5hzmk/2B8E8IbLYqw2wvc1IJ fYBmE6B8rRTj0xcDK0dAFv1aNjagyfk= X-Google-Smtp-Source: AA0mqf63Cemkb1su3zpH5Zs+MAblskWWH9Rfkq8M0HE1gR28it/2R9ZISSciiob6YEbJojZJZZYTvw== X-Received: by 2002:a17:90a:b908:b0:21a:8c6:c89e with SMTP id p8-20020a17090ab90800b0021a08c6c89emr37792968pjr.2.1671295963086; Sat, 17 Dec 2022 08:52:43 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:42 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 05/16] libcpu: Remove the need of NMNES by using enum Date: Sun, 18 Dec 2022 00:52:02 +0800 Message-Id: <20221217165213.152-6-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libcpu/Makefile.am | 2 +- libcpu/i386_disasm.c | 14 +------------- libcpu/i386_mne.h | 36 ++++++++++++++++++++++++++++++++++++ libcpu/i386_parse.y | 9 +++------ 4 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 libcpu/i386_mne.h diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am index 57d0a164..259ed838 100644 --- a/libcpu/Makefile.am +++ b/libcpu/Makefile.am @@ -92,7 +92,7 @@ libeu = ../lib/libeu.a i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \ -Wno-implicit-fallthrough i386_parse.o: i386_parse.c i386.mnemonics -i386_parse_CFLAGS = -DNMNES="`wc -l < i386.mnemonics`" +i386_parse_CFLAGS = i386_lex.o: i386_parse.h i386_gendis_LDADD = $(libeu) -lm $(obstack_LIBS) diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index 599d1654..c34f03d6 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -46,10 +46,7 @@ #define MACHINE_ENCODING LITTLE_ENDIAN #include "memory-access.h" - -#ifndef MNEFILE -# define MNEFILE "i386.mnemonics" -#endif +#include "i386_mne.h" #define MNESTRFIELD(line) MNESTRFIELD1 (line) #define MNESTRFIELD1(line) str##line @@ -71,15 +68,6 @@ static const union mnestr_t } }; -/* The index can be stored in the instrtab. */ -enum - { -#define MNE(name) MNE_##name, -#include MNEFILE -#undef MNE - MNE_INVALID - }; - static const unsigned short int mneidx[] = { #define MNE(name) \ diff --git a/libcpu/i386_mne.h b/libcpu/i386_mne.h new file mode 100644 index 00000000..41dacf61 --- /dev/null +++ b/libcpu/i386_mne.h @@ -0,0 +1,36 @@ +/* Compute hash value for given string according to ELF standard. + Copyright (C) 1995-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _I386_MNE_H +#define _I386_MNE_H 1 + +#ifndef MNEFILE +# define MNEFILE "i386.mnemonics" +#endif + +/* The index can be stored in the instrtab. */ +enum + { +#define MNE(name) MNE_##name, +#include MNEFILE +#undef MNE + MNE_INVALID, + MNE_COUNT = MNE_INVALID, + }; + +#endif /* i386_mne.h */ diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y index d2236d59..459684c6 100644 --- a/libcpu/i386_parse.y +++ b/libcpu/i386_parse.y @@ -46,6 +46,8 @@ #include #include +#include "i386_mne.h" + #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free @@ -1107,11 +1109,6 @@ print_op_fct (const void *nodep, VISIT value, } } - -#if NMNES < 2 -# error "bogus NMNES value" -#endif - static void instrtable_out (void) { @@ -1123,7 +1120,7 @@ instrtable_out (void) fprintf (outfile, "#define MNEMONIC_BITS %zu\n", best_mnemonic_bits); #else fprintf (outfile, "#define MNEMONIC_BITS %ld\n", - lrint (ceil (log2 (NMNES)))); + lrint (ceil (log2 (MNE_COUNT)))); #endif fprintf (outfile, "#define SUFFIX_BITS %d\n", nbitsuf); for (int i = 0; i < 3; ++i) From patchwork Sat Dec 17 16:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62092 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2F513AA9426 for ; Sat, 17 Dec 2022 16:53:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C2F513AA9426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296024; bh=u9aCt6m38yrrRcF0GDHlm7o5uG97qUxJdz0kqCOQOww=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=r+v9OJuKGk9Ql9bLWfVXHDZHg5Rcs6yzI9uO4pWBTmdGCqBA+YU3OZxbp9NHl4v3C biR2fI6m9Z//5pQYucWoVUWLUaLo9NVRXeRzXhtgLbnc7P5jh0AfRo0Nf/nTYH1Q8N q4443zUrHg7tjyqfMK9GBmQTnceOpL04eG/72oTs= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by sourceware.org (Postfix) with ESMTPS id 21F403AA9437 for ; Sat, 17 Dec 2022 16:52:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 21F403AA9437 Received: by mail-pj1-x1035.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so5227197pjd.5 for ; Sat, 17 Dec 2022 08:52:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u9aCt6m38yrrRcF0GDHlm7o5uG97qUxJdz0kqCOQOww=; b=p7KiAnPu7HKurYMPkGTARQcqN9t409mS3Vf6q4TxTtLVbNAwndkm+LOr2zMPmLQhOh cr8PEnJd732OfV5DNDpFw6sF2RKHpVxofv17F7sg/Ys/ti1AmlH04/wmNrR4HgspZTc/ R+iv/Pc/CPxTRrAq5ibDrHcycHs5tv1TRNBK+9BS6hjQ4+DxaD5DkPoPomT1dHcczxmK E/HRqzvzX+lQvew251B0FhP5Du1HiX63lAxm1twTCi02XIyE1wE3eVCoD7xN5Wn5hdpo M47ESeT2qNo62LPnTg3qn9l68a0anFdjvYCvgCUarUXFHNWBWz2HAkcnHieqWMoyE9rR hAlw== X-Gm-Message-State: AFqh2kp1nUVLyk8tPhoLCLFAFqx0Ao16twP0NE3ha1Z8VJounTfUEZ8o ZQ/V7EnqSHx4eOQ7EIfs4hORqySF7iI= X-Google-Smtp-Source: AMrXdXt+DzGWya01Ppjw3QSzXrc8Sdin3aQtv1sjXanVI6W2cAF1YUy8NqfaW9msWWo4ptpbvJfwwg== X-Received: by 2002:a17:90a:4f83:b0:219:c40:e3c with SMTP id q3-20020a17090a4f8300b002190c400e3cmr2869856pjh.33.1671295964894; Sat, 17 Dec 2022 08:52:44 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:44 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 06/16] libcpu: Use __asm instead asm that can be recognized by both clang-cl and gcc Date: Sun, 18 Dec 2022 00:52:03 +0800 Message-Id: <20221217165213.152-7-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" This block of code can not be removed. As it's contains a goto label enomem that been used elsewhere Signed-off-by: Yonggang Luo --- libcpu/i386_disasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index c34f03d6..44bf7d37 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -468,7 +468,7 @@ i386_disasm (Ebl *ebl __attribute__((unused)), /* gcc is not clever enough to see the following variables are not used uninitialized. */ - asm ("" + __asm ("" : "=mr" (opoff), "=mr" (correct_prefix), "=mr" (codep), "=mr" (next_curr), "=mr" (len)); } From patchwork Sat Dec 17 16:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62093 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C93293AA943A for ; Sat, 17 Dec 2022 16:53:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C93293AA943A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296035; bh=wpZvfhLZHnBw3IAGr8nVFlx71fXaU7y0FLfAxmaLQ/o=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=xwA7WKukxRHo6er5RpV91syEKwDqzfZcwXeZtWIfBItFrHQlw+0b1zS/JztLM6JwD CrHpMKuFohsaVrygibaJePl4g8C43LiAZJewPVlUopFAAECMWkdSIPYsZCOfA6t6RY vf/5I0Wllr8GIO6x5m7d4bDtVABktY/Xs60dko8o= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id EE3663AA9801 for ; Sat, 17 Dec 2022 16:52:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE3663AA9801 Received: by mail-pl1-x62a.google.com with SMTP id 4so5212261plj.3 for ; Sat, 17 Dec 2022 08:52:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wpZvfhLZHnBw3IAGr8nVFlx71fXaU7y0FLfAxmaLQ/o=; b=n8WuQP3sMJ6DrtEpxQcL2agusYKVkvgknfqt8fxGHWtLZGQ2wkRxcxqE0xiuvBbB0j dq34ZtKShCAqo3M6dDQmgBZ/M/zVTtrMkPrkDXZ9H5c/+ea34pQIp0DirgXAdTVxUC22 F6e6NKMUWFxL559nEBp7GcsK1cPPxXLSMFivO0j8yA+BWCCWPNwljcA2KBFH78z21ZNl ccwOqW2ZSxxmzWJwwoE0t+rFLZaabIkchutUzKET0Y6Lb2ophh1suFPfbDgMlATgO5qQ vhwPlzaEEp/phancW/0ba4eTsK1+CaDYmUAyIiwI+5hdhXMENMgbmZqwORIPzVdB6bc1 DcXA== X-Gm-Message-State: AFqh2kpP6qFcqDwVQj0yxm4g0+EjnRuvgpPZF8gIiif1FL0CDZ764B7X 06nUBMmVZo1NwbR5CcIpK+6dw2xNhrw= X-Google-Smtp-Source: AMrXdXv1JEIx6IKdeYmeVLs5iZkJbEf9r5InQxyhvldSApJHu3VTsvdn/xFU/8INZZSXcu/RvbcqKQ== X-Received: by 2002:a17:90a:8c01:b0:219:4b5:1775 with SMTP id a1-20020a17090a8c0100b0021904b51775mr2747691pjo.39.1671295966688; Sat, 17 Dec 2022 08:52:46 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:46 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 07/16] libdw: Fixes compile of dwarf_whatattr.c and dwarf_whatform.c Date: Sun, 18 Dec 2022 00:52:04 +0800 Message-Id: <20221217165213.152-8-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" If __OPTIMIZE__ is defined, then compile dwarf_whatattr.c and dwarf_whatform.c will cause symbol conflict between dwarf_whatattr.c and libdw.h, dwarf_whatform.c and libdw.h, So always undefined __OPTIMIZE__ when compiling these two files The error message is: dwarf_whatform.c [build] C:\work\xemu\elfutils\libdw\dwarf_whatform.c(39,1): error: redefinition of 'dwarf_whatform' [build] dwarf_whatform (Dwarf_Attribute *attr) [build] ^ [build] C:\work\xemu\elfutils\libdw/libdw.h(1110,1): note: previous definition is here [build] dwarf_whatform (Dwarf_Attribute *attr) [build] ^ [build] 1 error generated. Signed-off-by: Yonggang Luo --- libdw/dwarf_whatattr.c | 9 ++++----- libdw/dwarf_whatform.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libdw/dwarf_whatattr.c b/libdw/dwarf_whatattr.c index d664b021..01d92307 100644 --- a/libdw/dwarf_whatattr.c +++ b/libdw/dwarf_whatattr.c @@ -30,13 +30,12 @@ #ifdef HAVE_CONFIG_H # include #endif - +#ifndef __OPTIMIZE__ +#define __OPTIMIZE__ +#endif #include #include "libdwP.h" unsigned int -dwarf_whatattr (Dwarf_Attribute *attr) -{ - return attr == NULL ? 0 : attr->code; -} +dwarf_whatattr (Dwarf_Attribute *attr); diff --git a/libdw/dwarf_whatform.c b/libdw/dwarf_whatform.c index dee29a9f..9b3e41e6 100644 --- a/libdw/dwarf_whatform.c +++ b/libdw/dwarf_whatform.c @@ -30,13 +30,12 @@ #ifdef HAVE_CONFIG_H # include #endif - +#ifndef __OPTIMIZE__ +#define __OPTIMIZE__ +#endif #include #include "libdwP.h" unsigned int -dwarf_whatform (Dwarf_Attribute *attr) -{ - return attr == NULL ? 0 : attr->form; -} +dwarf_whatform (Dwarf_Attribute *attr); \ No newline at end of file From patchwork Sat Dec 17 16:52:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62097 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D47213AA981C for ; Sat, 17 Dec 2022 16:54:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D47213AA981C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296047; bh=qwJgBBNjzh3C1Zy4D5aPZHGdjlMelNYdlY7t7qckEWU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=IlM9wNlVKaglhDIUUzl8wk5R9VkxKN+a8bcBV4W7lop/bCUqtTQDV0HJO5CFM/dUl NG+7cUrP6Q9itgF9CwIQB5av8nvt++3PZXo+kDGQa8Dwv2l7Jn6hWXAjgPStCHkZIt bEXI3e+UDLfuWs84qhHtp3iv5RZtgFziuAfRZ1Ww= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id C3C0A3AA9802 for ; Sat, 17 Dec 2022 16:52:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C3C0A3AA9802 Received: by mail-pj1-x102e.google.com with SMTP id u5so5280133pjy.5 for ; Sat, 17 Dec 2022 08:52:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qwJgBBNjzh3C1Zy4D5aPZHGdjlMelNYdlY7t7qckEWU=; b=8P1eNaD1J0Zh1X/1N7bd13KBd11WGMb2AxYVS560CrizBE3wZhcDNpjXJ5gQ+kXH7p tUSdoAKJvzt5okiOzgWKREYf6cRhiC4iFkNH4wWBXcM40G6CzXZGPGO+oFT+gsn95g8m qgQA4ZMRsttCsHRTdMKJ+u3SYkAepSWOgMNuIaTAi/Om+nnoeA0mQGLJNUSq6hI+ezpg b7P1vUtUvSHwHpcT2PySRO6bH6NEU11zEPQKF8FDGpv/fKlNTmOsg5/ay9OAhHg/UjcY GgQRvl11jtHiSS9Pd16OWxVi23IBrzbQCj7HS4a4lZOP4PmIQoBLGQUhw8hbv2EQlO4Q Nqpg== X-Gm-Message-State: ANoB5pnZU/tzRdGLw1sykgyot+SmUjdCOE/I51QVl6zHMPcgIJaScPyc p8hpJhcPZS4JnIfEvm/OwpXKN9wumn0= X-Google-Smtp-Source: AA0mqf6ww4+A8w28Ly500yHhGmv5c/L/N3hNbpgrnsEQaFkFLkMehRWR4p1wgVKHoO6FS691F2VrIQ== X-Received: by 2002:a17:90a:ea0a:b0:219:211f:e2ae with SMTP id w10-20020a17090aea0a00b00219211fe2aemr38434565pjy.49.1671295968509; Sat, 17 Dec 2022 08:52:48 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:47 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 08/16] lib: Implement error properly even when not HAVE_ERR_H Date: Sun, 18 Dec 2022 00:52:05 +0800 Message-Id: <20221217165213.152-9-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" on win32, there is no err.h Signed-off-by: Yonggang Luo --- lib/error.c | 16 +++++++++++++++- lib/system.h | 4 +--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/error.c b/lib/error.c index 5186fc15..d4cbf0ff 100644 --- a/lib/error.c +++ b/lib/error.c @@ -28,12 +28,14 @@ #include -#if !defined(HAVE_ERROR_H) && defined(HAVE_ERR_H) +#if !defined(HAVE_ERROR_H) #include #include #include #include +#if defined(HAVE_ERR_H) #include +#endif unsigned int error_message_count = 0; @@ -44,6 +46,7 @@ void error(int status, int errnum, const char *format, ...) { fflush (stdout); va_start(argp, format); +#if defined(HAVE_ERR_H) if (status) { if (errnum) @@ -64,6 +67,17 @@ void error(int status, int errnum, const char *format, ...) { else vwarnx (format, argp); } +#else + if (errnum) + { + errno = errnum; + } + vfprintf(stderr, format, argp); + if (status) + { + _exit(status); + } +#endif va_end(argp); fflush (stderr); diff --git a/lib/system.h b/lib/system.h index 561d3e03..7f9f2a91 100644 --- a/lib/system.h +++ b/lib/system.h @@ -50,11 +50,9 @@ #if defined(HAVE_ERROR_H) #include -#elif defined(HAVE_ERR_H) +#else extern int error_message_count; void error(int status, int errnum, const char *format, ...); -#else -#error "err.h or error.h must be available" #endif /* error (EXIT_FAILURE, ...) should be noreturn but on some systems it From patchwork Sat Dec 17 16:52:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62100 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 58D383AA9802 for ; Sat, 17 Dec 2022 16:54:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 58D383AA9802 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296059; bh=WkjdKgikM8lQqVvpoElm4Qa2mG6bPEzSvINd5U512O0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=oSxg7iCbNJQinHXD1a7PwZqynnrSlBBG67OxlWC9HmaDHzLCQAhDMa8omHbHzerrH kprqe3OZvFpRXuXTKEOUoLfCuDrH0hit0LGoaURS3cD3girY4sf9oWqgtariBZ6adh eoU6YAlI+YjPuMfNQ1FEIylOzmJGqy9f9H8tpZXE= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id 0C2203AA9439 for ; Sat, 17 Dec 2022 16:52:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C2203AA9439 Received: by mail-pj1-x1032.google.com with SMTP id js9so5311398pjb.2 for ; Sat, 17 Dec 2022 08:52:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WkjdKgikM8lQqVvpoElm4Qa2mG6bPEzSvINd5U512O0=; b=qrQ8HYrWo9J9jt1QhoWX84Vj3U3gBUIEBFAjFRKTTkEmgeccKQJo+8Vt+zrvQDcdG7 GtXvKRm2CFHH4Sy6159I+XItM9mxR9trnq8KqUXvBTidTdmM6TAbjZYyD2v4wkB0H7CV is3WsLe5sWkLlq09cK6CIlSkD4WAl7t0r6ugo8ISYsMCwJrToKD9cUWQmh3I/Uk4JRkb lF41uQ6sbhPDL6fSEq1Hnf56dGSLGT1H7TmiBnV461XsiEc47A9PoB658ZuqRUuoW/T9 cPW4YBxJoIsnmITJ0vvmIfVxI0srU9iLak3tu03Sc5pNf3ezjpEiGO8B38jyjfwdxEJt SLqQ== X-Gm-Message-State: ANoB5pmE9TspYi5rfYu/WFi9F310ufSCwPLU3Tiwp5B0Sntda5g0fbO6 VLtrFVuk9w8u5HrgOjeqEKjbkII8SQw= X-Google-Smtp-Source: AA0mqf4jX5y/GMiEJ+CZYhAGGYLnj2dGl9ipcxAoPDwfjkMtYzcqrbkwougz5yJRUOjTwpxBf+qi9Q== X-Received: by 2002:a17:90b:306:b0:219:463d:4ebc with SMTP id ay6-20020a17090b030600b00219463d4ebcmr37792937pjb.30.1671295970348; Sat, 17 Dec 2022 08:52:50 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:49 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 09/16] libelf: uid_t, gid_t and mode_t are not comes with msvcrt, so using long/unsigned long instead on win32 Date: Sun, 18 Dec 2022 00:52:06 +0800 Message-Id: <20221217165213.152-10-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libelf/libelf.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libelf/libelf.h b/libelf/libelf.h index a139e733..2fa3838b 100644 --- a/libelf/libelf.h +++ b/libelf/libelf.h @@ -195,9 +195,15 @@ typedef struct { char *ar_name; /* Name of archive member. */ time_t ar_date; /* File date. */ +#if defined(_WIN32) + long ar_uid; + long ar_gid; + unsigned long ar_mode; +#else uid_t ar_uid; /* User ID. */ gid_t ar_gid; /* Group ID. */ mode_t ar_mode; /* File mode. */ +#endif int64_t ar_size; /* File size. */ char *ar_rawname; /* Original name of archive member. */ } Elf_Arhdr; From patchwork Sat Dec 17 16:52:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62094 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 525C23AA983B for ; Sat, 17 Dec 2022 16:54:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 525C23AA983B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296041; bh=LxcUJrqPhIRKreAVjYiV0vCLRQcD3MwyLeIdeKOgafg=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=dyWiSHT8PwPCqKoYdy8VsqpmaK4LNaDI8d87KHHpWkr2il3S4CbMPX1tFUgiro+n/ x2t8f+q5s+CkY54dT9xgwPmcLzDCD51bRHLK7TAg9YPjTf7g3ZJaOXS40yNyU1E5JH c3k/+d4Bw7iiRMWP9YhgbV17DeInfu+lqy+gb+C0= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 72E203AA941E for ; Sat, 17 Dec 2022 16:52:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 72E203AA941E Received: by mail-pj1-x1031.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so9078834pjj.2 for ; Sat, 17 Dec 2022 08:52:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LxcUJrqPhIRKreAVjYiV0vCLRQcD3MwyLeIdeKOgafg=; b=VKWDFUe2p2ki5Ez1D8n2sLCo7fO2vOe14zZLPO8pbR9gDIl6MwLObKFbgc3pUf2Y+D LHx9Dplaw8Z8h0XK/SvLut9ZzUVGBRFQj9Aw14N9D6FnL4VJn7FSOJY/vHUxsZ+Fu/fC gPo9zcbwvFV/T94tGq9sbsIZkpMyd4ZxjdAGiL4OQHsx570y9ncfQmOGhkWsU0S7W9Se f92HGmZ4c2DfooO25JZYBoYh9N3/1t3esOmcrVah7c5KKU1FSwCq92/W7fiMaJstRe1H LnS/tCcwfpqLOJXrXpc2deGDZWLDap5GLAbtxfCp9bTvOFvpEhOODXviBZuFBKiZvygm x5Xg== X-Gm-Message-State: AFqh2kpX/nE5G8KAuqWsUweWSHiHhEv/920gMQoSwNAQQXzMR/xC08q7 GXELNqIB++kIdTR6yhUULs1VI77LoUc= X-Google-Smtp-Source: AMrXdXvpEVWEnQMCBlaeQIt7OuaVxPqH43Nmig97BlguiB85av6YXsi84rNCZ9x/3uFx/6CM0j0yXA== X-Received: by 2002:a17:90a:cc18:b0:219:4011:b836 with SMTP id b24-20020a17090acc1800b002194011b836mr2681266pju.23.1671295972161; Sat, 17 Dec 2022 08:52:52 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:51 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 10/16] libasm: stdio_ext.h are not present on win32 Date: Sun, 18 Dec 2022 00:52:07 +0800 Message-Id: <20221217165213.152-11-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libasm/asm_begin.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libasm/asm_begin.c b/libasm/asm_begin.c index 9e4dfe43..9b6d974e 100644 --- a/libasm/asm_begin.c +++ b/libasm/asm_begin.c @@ -34,10 +34,13 @@ #include #include #include -#include #include #include +#if !defined(_WIN32) +#include +#endif + #include #include "libasmP.h" @@ -56,8 +59,10 @@ prepare_text_output (AsmCtx_t *result) free (result); result = NULL; } +#if !defined(_WIN32) else __fsetlocking (result->out.file, FSETLOCKING_BYCALLER); +#endif } return result; From patchwork Sat Dec 17 16:52:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62096 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 580BA3AA943E for ; Sat, 17 Dec 2022 16:54:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 580BA3AA943E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296042; bh=ibL7++OQoM7EyE+9/5O+zpaNaDuYIfoMk/NzQWLSBuw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=L9fwUHtXnKCxuZxmD4BioRpM+4NNnAINPvfrOBOjpzqDsfxP7gN0glzCry+oLMQd6 4M3gjLYSwijZGvhXJC3YibqKyYDFNkuXxCQOiAtRiu29fJCq7JpAWpE03z/asf5uL1 CVBJfN1OYj0XZQe1tI3kDCCFRDBZTirS9tKbrsQI= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 33CDD3AA9430 for ; Sat, 17 Dec 2022 16:52:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33CDD3AA9430 Received: by mail-pj1-x1030.google.com with SMTP id o12so5285782pjo.4 for ; Sat, 17 Dec 2022 08:52:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ibL7++OQoM7EyE+9/5O+zpaNaDuYIfoMk/NzQWLSBuw=; b=KCrqycuehdk+IBZFLlIkyWHDyyxkq9f2+zdbZSnd61Hwb8Zm4QRECtEdUv/J+yKD0S fiEc+tq5yF/0InzM4074nkOcP9CdDow1pKpHU0x8J814TBb/zYAV9IIQv8hXGxXavptG XBu1Zx2fSO3u3S0jf/SpRy/bSI80kqynFIE2UTO44/G3XdAD92YthKFX+pIcvFQpik15 baqhB5FI0ihrSo8lprnKj+0+TAkabOkbuJnpsrgsjrwk0YWYUa2aE5ddpqszpReOxRk+ LwrEs4zAAvQToVDtncN/MtNeL2nfmBHqzGccbBB9MZUCugT5bazvSCOpdJkbzU/O80lb xMHw== X-Gm-Message-State: ANoB5pm+RzDg35x+pM1mJgQXEZb5A2Sn43RrG7ZGpNMydvCDAy8WRtzc VGgGXBbhXLR1nECA1sgWRf0CjM2780s= X-Google-Smtp-Source: AA0mqf4aP9vo11522G5aclKJoOzeifEMiY4WgJ2BIprLGyzqM8n+ToPVWOXRw2tRL3okxwWo9dm7TA== X-Received: by 2002:a17:90b:310f:b0:219:d84:4446 with SMTP id gc15-20020a17090b310f00b002190d844446mr36772795pjb.26.1671295973982; Sat, 17 Dec 2022 08:52:53 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:53 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 11/16] libebl/libdwelf: define ssize_t and pid_t for MSVC within installed header libdwelf.h and libebl.h Date: Sun, 18 Dec 2022 00:52:08 +0800 Message-Id: <20221217165213.152-12-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libdwelf/libdwelf.h | 5 +++++ libebl/libebl.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/libdwelf/libdwelf.h b/libdwelf/libdwelf.h index 263ca60e..167ac0dc 100644 --- a/libdwelf/libdwelf.h +++ b/libdwelf/libdwelf.h @@ -31,6 +31,11 @@ #include "libdw.h" +#ifdef _MSC_VER +#include +typedef SSIZE_T ssize_t; +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/libebl/libebl.h b/libebl/libebl.h index 731001d3..c568f623 100644 --- a/libebl/libebl.h +++ b/libebl/libebl.h @@ -44,6 +44,11 @@ #include "elf-knowledge.h" +#ifdef _MSC_VER +#include +typedef SSIZE_T ssize_t; +typedef int pid_t; +#endif /* Opaque type for the handle. libasm.h defined the same thing. */ #ifndef _LIBASM_H From patchwork Sat Dec 17 16:52:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62098 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42B103AA9816 for ; Sat, 17 Dec 2022 16:54:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42B103AA9816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296053; bh=rbVelM/MgOrT6rKBYctYIGNyGIF6O+Yx193ds2IPhs4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=OhMN3gVjuRnOnQqix8yq2Q5cS7dSGhIciqGHAb8XR+vsAz2Hs/QRBGtfoUvQXV4xY GQAHbOwyKrIQhWZRP++JyfbSROalTLM4FmUqtSmgzeqzElAyw/vgrLG0/jbe/4Ll7f x4KSaWZaj9jV5cFpn3YKYbkioiEGH37m3Jn0N3js= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 6C3513AA9819 for ; Sat, 17 Dec 2022 16:52:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C3513AA9819 Received: by mail-pj1-x1031.google.com with SMTP id o1-20020a17090a678100b00219cf69e5f0so9078919pjj.2 for ; Sat, 17 Dec 2022 08:52:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rbVelM/MgOrT6rKBYctYIGNyGIF6O+Yx193ds2IPhs4=; b=AOHCoaK4Efx0szF9NBLa/0V/HvRN/O9WAvEs8wyH9RC0quA60SHeHeeShOBgOEz9wp 0Jlcf9Z1TEpKa3v+bc7/b4/uXCvmaFcECINFEMVT3/hCSfZLyraSivbEVREIvnplfJqb V+mA4eqdRrJ6c2lIrz1I16+GAjf87Q7kmWIblxq4Gsmp3HBco63+ep25KV7rCEb813UA PAdX7cmJrQ2y1x8aK4wOMATPt6+2O9lCFOZ9ncjnfkmRzycFasM4pRQULquLx67KSzSV dUtx4Z+Wxram25+iFUY0XkivDz3rOHjYG2ANhYmxiRWieG5b0DvCY0UWfwL1EJ8ixoui jWHQ== X-Gm-Message-State: AFqh2koBznF94KJ0ElTDpyp5x9m+fDcsOhG2Al9h5jgs9QmoJmtjhgoB XWCGtGfeMN00HMh8wHu5EipeE/f6NgE= X-Google-Smtp-Source: AMrXdXunI69MiBN9bsNuW0n4mGRf9xYs6kyOqq8aZSRkTlnT5P2zHXuHqlCcF+e7LHLtfd9Y1J+0Hw== X-Received: by 2002:a17:90a:d318:b0:219:23e5:dcbe with SMTP id p24-20020a17090ad31800b0021923e5dcbemr2739906pju.19.1671295975740; Sat, 17 Dec 2022 08:52:55 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:55 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 12/16] libasm/debuginfod: fchmod doesn't present on win32 Date: Sun, 18 Dec 2022 00:52:09 +0800 Message-Id: <20221217165213.152-13-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- debuginfod/debuginfod-client.c | 4 +++- libasm/asm_end.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 8873fcc8..7a67a440 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -1708,9 +1708,11 @@ debuginfod_query_server (debuginfod_client *c, tvs[0].tv_usec = tvs[1].tv_usec = 0; (void) futimes (fd, tvs); /* best effort */ +#if !defined(_WIN32) /* PR27571: make cache files casually unwriteable; dirs are already 0700 */ (void) fchmod(fd, 0400); - +#endif + /* rename tmp->real */ rc = rename (target_cache_tmppath, target_cache_path); if (rc < 0) diff --git a/libasm/asm_end.c b/libasm/asm_end.c index c06d2366..54540bc1 100644 --- a/libasm/asm_end.c +++ b/libasm/asm_end.c @@ -512,12 +512,14 @@ asm_end (AsmCtx_t *ctx) if (result != 0) return result; +#if !defined(_WIN32) /* Make the new file globally readable and user/group-writable. */ if (fchmod (ctx->fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) != 0) { __libasm_seterrno (ASM_E_CANNOT_CHMOD); return -1; } +#endif /* Rename output file. */ if (rename (ctx->tmp_fname, ctx->fname) != 0) From patchwork Sat Dec 17 16:52:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62095 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42A273AA9805 for ; Sat, 17 Dec 2022 16:54:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42A273AA9805 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296042; bh=66jzVvq3ZN+7lbp8CwAHNGRtXnz45vh1DN2S11XRPdU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=n46JNe26piuGsilCcNC1ntoZHiFYbGulWxq8IIfZkvgcRi3mYGSPZyUCInsiZqjM+ LZSxRwi1KHxC3pk64Szi+2KgFnbnAyn1IJ1RjmEbnGUcWYzFRyuYLQ2wSTR4clXrcs Ds5mvE5j/LK2LzJUdFH0gmmimDF1HUlvXMyZLxjs= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id B07533AA941F for ; Sat, 17 Dec 2022 16:52:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B07533AA941F Received: by mail-pj1-x102d.google.com with SMTP id n65-20020a17090a2cc700b0021bc5ef7a14so5297070pjd.0 for ; Sat, 17 Dec 2022 08:52:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=66jzVvq3ZN+7lbp8CwAHNGRtXnz45vh1DN2S11XRPdU=; b=4rItZ8JX7y5WLrn2562LWrRkmRcuL3dLdEVml1WyzasaYiCn07BI/+yZznWI5H79ax vTAXLd1OBiMgYbcARl4YNFIEZNHDSDIMpi9QCPfZXW/fax/YZYewoxNEJSLvF0/E2PvH RypHqzlvsktoSZkdijKdGbkwQfJREtX7DRa4vKpC2SZ0Rz7HWitLypfN/5TFGHa7oxDY RJw6g7XChaT5yHlc9pIdS4NDpMx07Csz25Cy+Le7sOkiV7MPZrBenTPslGB3JALDNOPb ZxbXT6mNCOGu5BHOiSxBWg/KSfAyCrJxtBqQSvM37/XwYKWj6bhvX2zUVb2LU3eGDZUY uQcA== X-Gm-Message-State: ANoB5pkHWFhlCby+r6FbEgX27ahrh7WqfhqaM9fbKa8q/Q+g1aVZgR4L qUQTiDEmK7rg+TqN8SPoByEHkABiUag= X-Google-Smtp-Source: AA0mqf5gffIZwGKBUSNq9hZBJymC08AKvPY2dES+3FIEOn5yYYQYeh2Jq+iBaq0TI23lNTfXTgJKKA== X-Received: by 2002:a17:90a:6c21:b0:223:1e7d:67e8 with SMTP id x30-20020a17090a6c2100b002231e7d67e8mr19266901pjj.16.1671295977449; Sat, 17 Dec 2022 08:52:57 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:57 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 13/16] lib: isatty is not available on windows Date: Sun, 18 Dec 2022 00:52:10 +0800 Message-Id: <20221217165213.152-14-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- lib/color.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/color.c b/lib/color.c index 8063dc26..963a2ec2 100644 --- a/lib/color.c +++ b/lib/color.c @@ -117,9 +117,14 @@ parse_opt (int key, char *arg, if (strcmp (arg, values[i].str) == 0) { color_mode = values[i].mode; +#ifdef _WIN32 + if (color_mode == color_auto) + color_mode = color_never; +#else if (color_mode == color_auto) color_mode = isatty (STDOUT_FILENO) ? color_always : color_never; +#endif break; } if (i == nvalues) From patchwork Sat Dec 17 16:52:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62101 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B3CAB3AA942E for ; Sat, 17 Dec 2022 16:54:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3CAB3AA942E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296070; bh=1DJQSW/ltjPjUpnn3zupMSwyW+JSuMDwPTyuOU9e/w8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=ROngNmoFbmGyCbh9mXNe6+7wHWUtbXW9VfLLoZ06Cd/I/GGLfG1LMiTfqCxPgm2Kx Sf7h/QBAZyxJjz6iEqVTbtZBlDnbpRvb9tWJOSYkgeDfJ9L7NBQKl3KTDh01pGapNB 2EDH7fQOVwcZ5eslluAGmK6ya9kCUR7wYN98ayNs= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 2A90F3AA9818 for ; Sat, 17 Dec 2022 16:53:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A90F3AA9818 Received: by mail-pl1-x62f.google.com with SMTP id w23so5162253ply.12 for ; Sat, 17 Dec 2022 08:53:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1DJQSW/ltjPjUpnn3zupMSwyW+JSuMDwPTyuOU9e/w8=; b=u79tMjLnlFLARqpEV+EWzcxKICV8GgQxkgHLaI2KPglP1Eew/DJsGikiJZ3cN1EhjR sglUFT1shW0P5YkgzL8yyyTTLkaHcLNrkmC6s7iwn2tMdXOBxbUVo7G9Aj6zJ217nS8T SQgqoUV2Eo5RNnZ3qHj0N8soFLnvgVGYod5XrO7tPDi0TkeM+s3d9mr0ro7MuJYX8FjM /ESQcL+TZnTg3+VAB+cpDhRGuOFkPiTC+/CIbyuC/3aIdWwXlT2QXtmY1nEY9p3Lnn3y xmuLJ/HVoj4KceQlPHNgl/K+MhhEDgQ1h9pjcIgvpVJWzJseO+XWevelGrCTZD4iSQcb J7/Q== X-Gm-Message-State: ANoB5pnDD313jrC6vK1J7sfXsUnxqYTCYGjLORzoBFvhRgfJUHC+qAMx z6HV145rVy0lhehLB0idljRNIsY7wxc= X-Google-Smtp-Source: AA0mqf6LygoSCof9TicqwaY+3bJ/XmTAYI8nMKk1mloRqJYoz07+CeZZX7kcc5hC4sSWjbeD2Cyoxw== X-Received: by 2002:a17:90a:300f:b0:221:6310:a4f3 with SMTP id g15-20020a17090a300f00b002216310a4f3mr23299819pjb.20.1671295979346; Sat, 17 Dec 2022 08:52:59 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:52:58 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 14/16] Add function sys_get_page_size to replace platform dependent sysconf (_SC_PAGESIZE) Date: Sun, 18 Dec 2022 00:52:11 +0800 Message-Id: <20221217165213.152-15-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- lib/Makefile.am | 2 +- lib/crc32_file.c | 2 +- lib/system.c | 48 ++++++++++++++++++++++++++++++++++ lib/system.h | 3 +++ libdw/dwarf_begin_elf.c | 2 +- libdwelf/dwelf_strtab.c | 2 +- libdwfl/linux-kernel-modules.c | 2 +- libdwfl/linux-proc-maps.c | 2 +- libelf/elf32_updatefile.c | 2 +- src/ar.c | 2 +- src/ranlib.c | 2 +- src/strings.c | 2 +- 12 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 lib/system.c diff --git a/lib/Makefile.am b/lib/Makefile.am index 42ddf5ae..7a50085b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -35,7 +35,7 @@ noinst_LIBRARIES = libeu.a libeu_a_SOURCES = xasprintf.c xstrdup.c xstrndup.c xmalloc.c next_prime.c \ crc32.c crc32_file.c \ - color.c error.c printversion.c + color.c error.c printversion.c system.c noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \ eu-config.h color.h printversion.h bpf.h \ diff --git a/lib/crc32_file.c b/lib/crc32_file.c index 66833702..45e1cc52 100644 --- a/lib/crc32_file.c +++ b/lib/crc32_file.c @@ -52,7 +52,7 @@ crc32_file (int fd, uint32_t *resp) void *mapped = mmap (NULL, mapsize, PROT_READ, MAP_PRIVATE, fd, 0); if (mapped == MAP_FAILED && errno == ENOMEM) { - const size_t pagesize = sysconf (_SC_PAGESIZE); + const size_t pagesize = sys_get_page_size(); mapsize = ((mapsize / 2) + pagesize - 1) & -pagesize; while (mapsize >= pagesize && (mapped = mmap (NULL, mapsize, PROT_READ, MAP_PRIVATE, diff --git a/lib/system.c b/lib/system.c new file mode 100644 index 00000000..bd3831f5 --- /dev/null +++ b/lib/system.c @@ -0,0 +1,48 @@ +/* Definitions for system functions. + Copyright (C) 2006-2011 Red Hat, Inc. + Copyright (C) 2022 Mark J. Wielaard + Copyright (C) 2022 Yonggang Luo + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see . */ + +#include + +#include "system.h" +#if defined(_WIN32) +#include +#endif + +size_t +sys_get_page_size(void) +{ +#ifdef _WIN32 + SYSTEM_INFO info; + GetSystemInfo(&info); + return info.dwPageSize; +#else + return sysconf (_SC_PAGESIZE); +#endif +} diff --git a/lib/system.h b/lib/system.h index 7f9f2a91..c84c416c 100644 --- a/lib/system.h +++ b/lib/system.h @@ -200,6 +200,9 @@ pread_retry (int fd, void *buf, size_t len, off_t off) return recvd; } +size_t +sys_get_page_size(void); + /* The demangler from libstdc++. */ extern char *__cxa_demangle (const char *mangled_name, char *output_buffer, size_t *length, int *status); diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index 8fcef335..0f13e2f5 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -502,7 +502,7 @@ dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp) /* Default memory allocation size. */ - size_t mem_default_size = sysconf (_SC_PAGESIZE) - 4 * sizeof (void *); + size_t mem_default_size = sys_get_page_size() - 4 * sizeof (void *); assert (sizeof (struct Dwarf) < mem_default_size); /* Allocate the data structure. */ diff --git a/libdwelf/dwelf_strtab.c b/libdwelf/dwelf_strtab.c index c95f9467..293b2d93 100644 --- a/libdwelf/dwelf_strtab.c +++ b/libdwelf/dwelf_strtab.c @@ -86,7 +86,7 @@ dwelf_strtab_init (bool nullstr) { if (ps == 0) { - ps = sysconf (_SC_PAGESIZE); + ps = sys_get_page_size(); assert (sizeof (struct memoryblock) < ps - MALLOC_OVERHEAD); } diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 58c0c417..65a58616 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -550,7 +550,7 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes) *notes = *end; } - Dwarf_Addr round_kernel = sysconf (_SC_PAGESIZE); + Dwarf_Addr round_kernel = sys_get_page_size(); *start &= -(Dwarf_Addr) round_kernel; *end += round_kernel - 1; *end &= -(Dwarf_Addr) round_kernel; diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c index 719cba68..40b8050b 100644 --- a/libdwfl/linux-proc-maps.c +++ b/libdwfl/linux-proc-maps.c @@ -422,7 +422,7 @@ dwfl_linux_proc_find_elf (Dwfl_Module *mod __attribute__ ((unused)), if (fd < 0) goto detach; - *elfp = elf_from_remote_memory (base, sysconf (_SC_PAGESIZE), NULL, + *elfp = elf_from_remote_memory (base, sys_get_page_size(), NULL, &read_proc_memory, &fd); close (fd); diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index 8229fd26..af4518b8 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -474,7 +474,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum) /* Make sure the content hits the disk. */ char *msync_start = ((char *) elf->map_address - + (elf->start_offset & ~(sysconf (_SC_PAGESIZE) - 1))); + + (elf->start_offset & ~(sys_get_page_size() - 1))); char *msync_end = ((char *) elf->map_address + elf->start_offset + ehdr->e_shoff + ehdr->e_shentsize * shnum); diff --git a/src/ar.c b/src/ar.c index 3bcb18fe..d01f8482 100644 --- a/src/ar.c +++ b/src/ar.c @@ -428,7 +428,7 @@ copy_content (Elf *elf, int newfd, off_t off, size_t n) assert (off + n <= len); /* Tell the kernel we will read all the pages sequentially. */ - size_t ps = sysconf (_SC_PAGESIZE); + size_t ps = sys_get_page_size(); if (n > 2 * ps) posix_madvise (rawfile + (off & ~(ps - 1)), n, POSIX_MADV_SEQUENTIAL); diff --git a/src/ranlib.c b/src/ranlib.c index 7838d69e..645b40ae 100644 --- a/src/ranlib.c +++ b/src/ranlib.c @@ -122,7 +122,7 @@ copy_content (Elf *elf, int newfd, off_t off, size_t n) assert (off + n <= len); /* Tell the kernel we will read all the pages sequentially. */ - size_t ps = sysconf (_SC_PAGESIZE); + size_t ps = sys_get_page_size(); if (n > 2 * ps) posix_madvise (rawfile + (off & ~(ps - 1)), n, POSIX_MADV_SEQUENTIAL); diff --git a/src/strings.c b/src/strings.c index 55b047be..3341760d 100644 --- a/src/strings.c +++ b/src/strings.c @@ -163,7 +163,7 @@ main (int argc, char *argv[]) elf_version (EV_CURRENT); /* Determine the page size. We will likely need it a couple of times. */ - ps = sysconf (_SC_PAGESIZE); + ps = sys_get_page_size(); struct stat st; int result = 0; From patchwork Sat Dec 17 16:52:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62102 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C14BB3AA9422 for ; Sat, 17 Dec 2022 16:54:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C14BB3AA9422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296081; bh=kdvUToojEJX7qPBoy/cOVqvj/5wfErbx540v6xtDHyA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=WJFEAKS3k/1SkkSuq8ao5yh50jWzRrEZTfsvA/XR9kmoM0mEg3BjDcl8hCxBwMcfn mKhfRoA319/p32XXk+fEryOKB1k/QaxxS7kuHLh4tSlE12iQ4GJ+9J9nqXb4f7ZgoM O41bTKbDqvFJNO5yLDuynslm0oO8Wn3+P6MXs19s= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id 664263AA9828 for ; Sat, 17 Dec 2022 16:53:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 664263AA9828 Received: by mail-pl1-x629.google.com with SMTP id d15so5199732pls.6 for ; Sat, 17 Dec 2022 08:53:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kdvUToojEJX7qPBoy/cOVqvj/5wfErbx540v6xtDHyA=; b=HkE0LtLhEXOZ04Zhw9RHe1KeBoaPRNZBlVFgmFUUpe4QFCCng2JIEf1T0HGnd8jrSC DPQHOED24TIbeX4AInx58dRuG5rq1rPmHiMmcUS91l4wE5wQ8/ryBYHQ+bF3Y9hWx0NX Q2/FrPn/JJvxUs3yb0rmqlTSKkMi8VjQ55NIto2JyQQjIxEadew9Celsrx4fE3fdCLz1 PcC/CqELmgKc2rDs69iEEEH+9PamkdkCtv/4qLrm2prPK1jKXvta3k/IIEy0PmrH586z s8hnCxDonNoLiFNkFzCOcKCjARtPUsw9mbK/Y7NrZ3BcfOh9KierKuxOKqAA6rysyAQ7 xMqQ== X-Gm-Message-State: ANoB5pnhm5H1KrgvZuTG8uzxcEM1jSMCjH5zSKYllv/yX5oKienPwhll cjrPFhFQV+t/NIqEH0OGP+2abUpEmNw= X-Google-Smtp-Source: AA0mqf47IGEPdC+P2r2dogYJ9l4PrbBDMJPX53BcdQBk6V+FXWtqjMnAeQaf8UVFTLSSyWEU11Ocxw== X-Received: by 2002:a17:90a:eb88:b0:219:986d:696f with SMTP id o8-20020a17090aeb8800b00219986d696fmr37668364pjy.22.1671295981155; Sat, 17 Dec 2022 08:53:01 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:53:00 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 15/16] libelf: F_GETFD may not predefined with msvc/mingw, guard the usage of it Date: Sun, 18 Dec 2022 00:52:12 +0800 Message-Id: <20221217165213.152-16-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Signed-off-by: Yonggang Luo --- libelf/elf_begin.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c index 6d31882e..3d324694 100644 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -1163,12 +1163,19 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref) if (ref != NULL) /* Make sure the descriptor is not suddenly going away. */ rwlock_rdlock (ref->lock); +#if defined(F_GETFD) else if (unlikely (fcntl (fildes, F_GETFD) == -1 && errno == EBADF)) { /* We cannot do anything productive without a file descriptor. */ __libelf_seterrno (ELF_E_INVALID_FILE); return NULL; } +#else + else if (fildes < 0) + { + return NULL; + } +#endif switch (cmd) { From patchwork Sat Dec 17 16:52:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yonggang Luo X-Patchwork-Id: 62099 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C741C3AA943D for ; Sat, 17 Dec 2022 16:54:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C741C3AA943D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671296053; bh=QzqJjgq2Wg3PQFpPrTB068GWw+gudae3/+fzkmb9O20=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Help:List-Subscribe:From: Reply-To:From; b=I8GrwYgi24Y8iC711eNx8R5Bq/rgVSDAvTInqYxLkgm3cbYOkVOPu17t30wCAHEbp 70bMKx0uQdHC5WKRA3dwT3T1KojM1fsqDoY0RcHT7cdFqb43RJt5kxhA3lEUynJq3F BYFNwcgroY4R3/x2Y7qN2AUcWjcGMUZB6EdO7x6s= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 60A583AA9803 for ; Sat, 17 Dec 2022 16:53:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 60A583AA9803 Received: by mail-pl1-x630.google.com with SMTP id t2so5221395ply.2 for ; Sat, 17 Dec 2022 08:53:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QzqJjgq2Wg3PQFpPrTB068GWw+gudae3/+fzkmb9O20=; b=gxPej3mnRReYRRsb+ptVdOv1EPUlzyQZ1008GdOMkAHcDYRGg/6SMVeSWuyBUEujd5 qRxBxUg/7phjrSztFkC3Pnq6HOTPJH3Bc4l+3kAsHgUGdIlZVAMObyweEaRepZaO0wk+ sy/FWyQd1YVYkteoaTF/DCVSHxH8iF0Obnx5yiX+D5iJZWtQ9wKb073Mb72suv5zkJCS YnHtT2jXh0GzKmiyU0AQCbCCPKyvYZuwgdTodub33t8BSsgPrjkWNZxKj8n83s8I0Qmn KTVbnHXwnvP2scvcbR6lBhse0FjrNFeHGuXEp8xc6kKa7EsVKY+NPuZOWySpV2tnJbqd WgQw== X-Gm-Message-State: ANoB5plBMHz1oood8X+MnCxCs4zh+bwY8GAe5/5m6+5hqqA0SVjHG0yg udYyaWCyJxbUEAGaxPfL4NCzUlHQlKw= X-Google-Smtp-Source: AA0mqf5Y9xNleqli3icXlogopAMv7dJN6m60Hu0aPqp4YDRZbu0KSoCKPfQ/81v5E7dhm7aYUxYIoQ== X-Received: by 2002:a17:90a:3188:b0:219:3e5f:2a65 with SMTP id j8-20020a17090a318800b002193e5f2a65mr37873026pjb.36.1671295983092; Sat, 17 Dec 2022 08:53:03 -0800 (PST) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id s92-20020a17090a2f6500b002191873187dsm6643229pjd.33.2022.12.17.08.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 08:53:02 -0800 (PST) To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH v2 16/16] lib: Use HAVE_LIBINTL_H to guard #include Date: Sun, 18 Dec 2022 00:52:13 +0800 Message-Id: <20221217165213.152-17-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221217165213.152-1-luoyonggang@gmail.com> References: <20221217165213.152-1-luoyonggang@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yonggang Luo via Elfutils-devel From: Yonggang Luo Reply-To: Yonggang Luo Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" MSVC doesn't have libintl.h, so use macro to guard it. Signed-off-by: Yonggang Luo --- configure.ac | 2 ++ lib/eu-config.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/configure.ac b/configure.ac index b84623fe..aea12be3 100644 --- a/configure.ac +++ b/configure.ac @@ -441,6 +441,8 @@ AC_CHECK_FUNCS([process_vm_readv mremap]) AS_IF([test "x$ac_cv_func_mremap" = "xno"], [AC_MSG_WARN([elf_update needs mremap to support ELF_C_RDWR_MMAP])]) +AC_CHECK_HEADERS([libintl.h]) + AC_CHECK_HEADERS([error.h]) AC_CHECK_HEADERS([err.h]) diff --git a/lib/eu-config.h b/lib/eu-config.h index 78a5c4fe..72b7793e 100644 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@ -52,10 +52,17 @@ # define rwlock_unlock(lock) ((void) (lock)) #endif /* USE_LOCKS */ +#if defined(HAVE_LIBINTL_H) #include +#endif + /* gettext helper macros. */ #define N_(Str) Str +#if defined(HAVE_LIBINTL_H) #define _(Str) dgettext ("elfutils", Str) +#else +#define _(Str) N_(Str) +#endif /* Compiler-specific definitions. */ #define strong_alias(name, aliasname) \