From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 48C091F44D for ; Sun, 24 Mar 2024 05:50:48 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=d2QrkVWr; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7461D3858D33 for ; Sun, 24 Mar 2024 05:50:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7461D3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711259445; bh=qBxSA3Xd3LDFeZPw5y4JxgsHou3n3M7v/F2/84HqL8I=; h=From:Date:Subject:To:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=d2QrkVWrvFAUPgzQDb+y8d8070Kdz9KGFXx2wa43nB8yav2NmS5BpZ6RxZde+gYlU QeWC66BqVsoo3kEzYuGTFawSpPuD53bUmp/YF0pwd2m1WBT2kBbwiOnTix5+Md3hRi FsLccVywLbcGiqCET/vjj5zNfEzF8p0cAdcdAcb4= Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by sourceware.org (Postfix) with ESMTPS id 316983858D33 for ; Sun, 24 Mar 2024 05:50:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 316983858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 316983858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.219.41 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711259414; cv=none; b=RhWoYSK62lIR52OysrnPrr+0UnEdcW8vGnq6GQFP9NDgaNmbeZloGE8m+hpRccs+3FOCpRMD+4vbwA/PWiSECXPdT55dK9EYrXhx1vm7hOWwnPuljQPbnfwHUp0Vl9PHw9KJuYTpBRx7XA0bo0oyGqnHn+FXLYwHC6khIKeWGxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711259414; c=relaxed/simple; bh=qBxSA3Xd3LDFeZPw5y4JxgsHou3n3M7v/F2/84HqL8I=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=uX29O3myQwQqFyFe5ylC8mamfF5VHT0iEXBCrwlg6oFHnNX5mgXEfK1YXPokC327PH7WtYuCeBQ2JBdN7X1JZjD20fWxRPStkgqBXa7PelFXwUeLgfL2OWEUEjntyASlBmIq30WskH8uuKkQeUBXkmQrB94O/zKOhldROLu/82U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6962e6fbf60so34705086d6.1 for ; Sat, 23 Mar 2024 22:50:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711259412; x=1711864212; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=qBxSA3Xd3LDFeZPw5y4JxgsHou3n3M7v/F2/84HqL8I=; b=EBJ8i2jr3z225MHo9YUJ7PxDb+XzwyHKiv1X/DorLxkUDEIBqV0ExNaax+HC/fmYEJ FVbHDHodWbGKJ0PTV/HJw8NUWOtC1fvw4YznVcPw+KRypUlU0PCgbMHP0vHYKyDQuUy6 fORXYSQyKQHLrebqNQrcfFpbD8ENg58lyFn2ANtbG4cX+TMh38c9aOXYnKaKnhrlRxB8 DkR7UGW9+fEW9SZRevv5XcL7CaP3Ovh054sSzRG2EiVsRFqTxBVo5sKe54Ib02V6boWq 4S7yeQ3aEVMPAJxlj1nj5ILRks7Q6vOurkRD0vZaS935NTTLy+MKyzwy93v7/k5cSoLz kRiQ== X-Gm-Message-State: AOJu0YxqzCGeawoi/tpwAp1fLdhhW+yC3f7l2Npvz2vgBoPZPqaAk+nu IJ1tTl4FXgVJ4t5F041wCkqFh8xDoeepJwjhQMVfjMFHlQDYET7/CJp2cB4Y X-Google-Smtp-Source: AGHT+IFhXQnyCR2KbhqZ8/xP8zKcKqVP6Amkz2E8EXSeRBoP5E6R4V1XUSTe/uKtwlntMHJk3QItkA== X-Received: by 2002:a05:6214:23c9:b0:691:6bf3:e6d1 with SMTP id hr9-20020a05621423c900b006916bf3e6d1mr3901364qvb.33.1711259412361; Sat, 23 Mar 2024 22:50:12 -0700 (PDT) Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com. [209.85.219.48]) by smtp.gmail.com with ESMTPSA id jv14-20020a05621429ee00b00696893597cfsm201999qvb.13.2024.03.23.22.50.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Mar 2024 22:50:12 -0700 (PDT) Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-6963cf14771so31261886d6.3 for ; Sat, 23 Mar 2024 22:50:12 -0700 (PDT) X-Received: by 2002:a05:6214:21ab:b0:690:3ca2:1858 with SMTP id t11-20020a05621421ab00b006903ca21858mr4369525qvc.4.1711259411886; Sat, 23 Mar 2024 22:50:11 -0700 (PDT) MIME-Version: 1.0 From: Fangrui Song Date: Sat, 23 Mar 2024 22:50:01 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: CREL dynamic relocations To: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org I have proposed a compact relocation format CREL at https://groups.google.com/g/generic-abi/c/yb0rjw56ORw/m/eiBcYxSfAQAJ (previously named RELLEB). CREL primarily targets static relocations, achieving significant .o file size reduction for lld builds: 18.0% for x86-64/aarch64 and 34.3% for riscv64. CREL holds promise for dynamic relocations as well, surpassing Android's packed relocation format. * R_*_GLOB_DAT and R_*_JUMP_SLOT relocations can typically be encoded with repeated 0x09 0x01 (when shift==3, offset++, symidx++). * Absolute relocation (__cxa_pure_virtual@CXXABI_1.3 + 0) relocations typically require just one byte (offset+=n) While CREL's benefit for non-relative relocations is smaller than RELR's optimizing for relative relocations, it still shines for programs where non-relative relocations make up more than 5% of the file size (quite a few GUI libraries, probably due to C++ virtual tables). We could even consider phasing out REL/RELA for new architectures in favor of CREL. I'd love to hear your feedback on CREL and hope someone might consider implementing rtld support (and binutils support if you like that as well:) ) https://sourceware.org/bugzilla/show_bug.cgi?id=31541 I've notified binutils and GCC folks at https://sourceware.org/pipermail/binutils/2024-March/133153.html ("CREL relocation format for ELF (was: RELLEB)").