From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 62A973858D28 for ; Fri, 7 Jun 2024 21:22:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62A973858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 62A973858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717795356; cv=none; b=q7OntY+tjgqT1PvO1DlzMQPiCYycLcardNqekPOhN6UB8Gum8c08x7cB/NPXzYu9s47NrExtX2WNOUeCYumqz+7tK8HPFKoz29mubpijGOMbKe3RSjYjKwg+tHysgCw/xQWRp4yvW57kzBHYp+BTRBDSZceSGg1E5kRsIo3WKLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717795356; c=relaxed/simple; bh=SgmTHXc+I8IDk1rchlSdw/ro2YOY+Dvg4MgTUsfDMNc=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=B2nN917RE4nDtSrUC80WIpI+G460vsJFanEoHgLfra6ChdmNPXtDwgpL+U96qbMAbDIoS8VnhQopxDyrhVJDDSZWPrsMvp6kngBhi7zCOilOiz01ZSOhEZca6CwDhEWwEKIhW16+Z54VYtFKg3uCgtc5j1cylDaQNYTHuiq/qnU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717795355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type; bh=7WOI1oaAw+SbxblXyrDIY5lbk0JpDRjgLeJZ0yfbmwE=; b=gfxsXZhIX6yj+putUDjvFv9+TajdN5AGj84ysr3PAGkH2NfSajyQoXe8SrhBN52wFbtxLa df2ICTAci0v0Eqs+ypGkXmIL6AxOHIbTm3Q3/4EQjbo2xdMMduJkcahOc4THhznk9cSUXY U8kN4OGh+Y5gydMtCHeDVmb0QyCFZv8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-M__GjOQLOVqez7nqYRM6zQ-1; Fri, 07 Jun 2024 17:22:32 -0400 X-MC-Unique: M__GjOQLOVqez7nqYRM6zQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 97ABA85A5B5 for ; Fri, 7 Jun 2024 21:22:32 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.10.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8082F3C23 for ; Fri, 7 Jun 2024 21:22:32 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.16.1/8.16.1) with ESMTP id 457LMQf11268898 for ; Fri, 7 Jun 2024 17:22:26 -0400 Date: Fri, 07 Jun 2024 17:22:26 -0400 Message-Id: From: DJ Delorie To: libc-alpha@sourceware.org Subject: elf: sort tunables list from ld.so X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: sort output from "ld.so --list-tunables" diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index 147cc4cf23..f79fa0827e 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -357,9 +357,28 @@ __tunables_init (char **envp) void __tunables_print (void) { - for (int i = 0; i < array_length (tunable_list); i++) + int i, j; + int sortmap [array_length (tunable_list)]; + + for (i = 0; i < array_length (tunable_list); i++) + sortmap [i] = i; + /* Quick bubble sort is sufficient. */ + for (i = 0; i < array_length (tunable_list) - 1; i++) + for (j = i+1; j < array_length (tunable_list); j++) + { + const char *ni = tunable_list[sortmap[i]].name; + const char *nj = tunable_list[sortmap[j]].name; + if (strcmp (ni, nj) > 0) + { + int t = sortmap[i]; + sortmap[i] = sortmap[j]; + sortmap[j] = t; + } + } + + for (i = 0; i < array_length (tunable_list); i++) { - const tunable_t *cur = &tunable_list[i]; + const tunable_t *cur = &tunable_list[sortmap[i]]; if (cur->type.type_code == TUNABLE_TYPE_STRING && cur->val.strval.str == NULL) _dl_printf ("%s:\n", cur->name);