From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id DA32D3858D39; Tue, 26 Oct 2021 18:39:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA32D3858D39 Received: by mail-pl1-x636.google.com with SMTP id t21so188361plr.6; Tue, 26 Oct 2021 11:39:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wwPVfhWmv6/7/KXNo5m4PT7XbZWwc1bRtAW1Qg9cCGk=; b=TgSQ+jWhcglGNBbvZPPxcMHg9neOWj+wyeV/UUlGOqvQsVGACS4OJYbkQai80AvhZp 8OOSs82wV4UisUosrUTesi4dV7nIGs/7pA+BP/y/8NI4vIN3D+2J3+lIuAHBgaJX1ig7 SEvayuuKs50StC0ReHd+1qwsn3B7HDeBGKdikLobDhdON24G2cK77QJfXouwv26w8cKj L9PeJDRnenZoYN6qH+dZOAX+Vguz1eNvlXgs7it0N3fM8cvHX48dp7FwLXbkC7FedIO6 rU1onnJf+tkaKRSaOS9nuBuUdWbs9SNUsaTqiTt0xhrWEjxwXBGJW8le0SWGWq6kgt5k pxqw== X-Gm-Message-State: AOAM531/N/TXuGFItRqWe5rkgOkT9vBa2aTz53EQ/JWjIX2l0RIyhqki Pw6z8Ewum6jkSRCN1y6koY6gtcJNBBQscl+vzY4= X-Google-Smtp-Source: ABdhPJwCzfY6/IFuO8/L34Xcw3zaHAm24H17IWtbWKaEfM4TIIvgPBK6uaSLiO3ZasQ7o96L/o0xHUce9pppZMj+tJs= X-Received: by 2002:a17:902:cec7:b0:140:4a11:799f with SMTP id d7-20020a170902cec700b001404a11799fmr15395406plg.27.1635273594895; Tue, 26 Oct 2021 11:39:54 -0700 (PDT) MIME-Version: 1.0 References: <87zgqvq03g.fsf@oldenburg.str.redhat.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 26 Oct 2021 11:39:19 -0700 Message-ID: Subject: v2: RFC: Add GNU_PROPERTY_1_GLIBC_2_NEEDED To: Florian Weimer Cc: "H.J. Lu via Libc-alpha" , Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3022.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Oct 2021 18:39:57 -0000 Here is the v2 proposal. -- H.J. -- Motivations: 1. Some binaries which require new ELF features, like DT_RELR, only work with the new glibc binary. They crash at run-time with the older glibc binaries. 2. Somes binaries compiled with the new language features, like C2X printf specifiers, only generate correct results with the new glibc binary. Since we don't add new glibc versions to the printf function family, they generate incorrect results at run-time with the older glibc binaries. Here is a proposal to encode glibc version dependencies in relocatable objects: /* The needed glibc 2 minor version property for the object file. */ #define GNU_PROPERTY_1_GLIBC_2_NEEDED (GNU_PROPERTY_UINT32_OR_LO + 1) /* The needed glibc 2 minor base version. */ #define GNU_PROPERTY_1_GLIBC_2_NEEDED_MINOR_BASE 35 /* Set if the object file requires glibc 2 minor version M. */ #define GNU_PROPERTY_1_GLIBC_2_NEEDED_MINOR_VERSION(m) \ (1U << ((m) - GNU_PROPERTY_1_GLIBC_2_NEEDED_MINOR_BASE)) Linker adds glibc versions in GNU_PROPERTY_1_GLIBC_2_NEEDED to the .gnu.version_r section and removes GNU_PROPERTY_1_GLIBC_2_NEEDED note when generating shared libraries and executables. [hjl@gnu-cfl-2 elfvers-1]$ ./readelf -n x.o Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 Properties: x86 ISA used: x86 feature used: x86 [hjl@gnu-cfl-2 elfvers-1]$ ./readelf -n glibc-2-minor-1.o Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: 1_glibc_2_needed: 2.35, 2.38 GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 Properties: x86 ISA used: x86 feature used: x86 [hjl@gnu-cfl-2 elfvers-1]$ make x gcc -B./ -o x x.o glibc-2-minor-1.o [hjl@gnu-cfl-2 elfvers-1]$ ./readelf -n --version-info x Version symbols section '.gnu.version' contains 4 entries: Addr: 0x00000000004004ae Offset: 0x0004ae Link: 6 (.dynsym) 000: 0 (*local*) 2 (GLIBC_2.34) 3 (GLIBC_2.2.5) 1 (*global*) Version needs section '.gnu.version_r' contains 1 entry: Addr: 0x00000000004004b8 Offset: 0x0004b8 Link: 7 (.dynstr) 000000: Version: 1 File: libc.so.6 Cnt: 4 0x0010: Name: GLIBC_2.38 Flags: none Version: 5 0x0020: Name: GLIBC_2.35 Flags: none Version: 4 0x0030: Name: GLIBC_2.2.5 Flags: none Version: 3 0x0040: Name: GLIBC_2.34 Flags: none Version: 2 ... [hjl@gnu-cfl-2 elfvers-1]$ ./x ./x: /lib64/libc.so.6: version `GLIBC_2.38' not found (required by ./x) ./x: /lib64/libc.so.6: version `GLIBC_2.35' not found (required by ./x) [hjl@gnu-cfl-2 elfvers-1]$