From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by sourceware.org (Postfix) with ESMTPS id 3C231384F965 for ; Wed, 14 Dec 2022 20:05:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3C231384F965 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f178.google.com with SMTP id d7so4505042pll.9 for ; Wed, 14 Dec 2022 12:05:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=waP7x/EWYyyI+44hhzLSYjmDovmpcslYl9ONgUKGKlg=; b=djDnZklIlNMh71qVtZLT0jWKTkO1QlMczvrTfdrgMbyyvwu9AkV6HwQhOSHECmpKKb SUbARlqeyTuf4tPMSZ+Gn3bfQTfYAnV5GZPCSOyBj6a04+pVZ8vplRiJsSnBXcRZ7gad aBY9XjP7zREc7fQERDYPM0SB29YybPlqjPImuYwQVs9p5KIel4pM1BpYKqLrqUQtn3oE vCxgmYJr/6yagcs3QT2upGQjYCmssn9ltq84iMsqcD9HN2gEDUgomc31qdqqNEhL9n/j /4mlprymIUBZqaG41Sqn7zzw3fwOv3AiOb/YKZdJ2CKqeDvEier4dyIi13W6Jya6I8YH hwJQ== X-Gm-Message-State: ANoB5plj1tOnneSIuLKF9k2HvEszsQ3gO1z4t+skjdKZkjay95TgD+/y c7dJpAY7HKYGaBv2LZKzu5C7xbR5etg= X-Google-Smtp-Source: AA0mqf7UvKugDR3X4bL192WnV5/7hmXWI+BlloprQdvl/+AAmGN4dl/A5spzs28Z5Vryl9ic7Bo65g== X-Received: by 2002:a05:6a20:be19:b0:9e:7bfe:ceae with SMTP id ge25-20020a056a20be1900b0009e7bfeceaemr25833314pzb.26.1671048323134; Wed, 14 Dec 2022 12:05:23 -0800 (PST) Received: from localhost ([64.129.1.8]) by smtp.gmail.com with ESMTPSA id v6-20020aa799c6000000b0056bc5ad4862sm271372pfi.28.2022.12.14.12.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 12:05:22 -0800 (PST) Date: Wed, 14 Dec 2022 10:05:20 -1000 From: Fangrui Song To: Florian Weimer Cc: Nick Clifton , binutils@sourceware.org Subject: Re: Named local symbols in the ELF dynamic symbol table Message-ID: <20221214200520.xjo2hbydr2znowxr@gmail.com> References: <87y1rke9ub.fsf@oldenburg.str.redhat.com> <15cc745d-b635-daab-4a02-918a5ea5d923@redhat.com> <87edt8jxag.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87edt8jxag.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I have only seen one reason where STB_LOCAL symbols in .dynsym are useful: unaligned absolute relocations for ppc32/ppc64 https://sourceware.org/bugzilla/show_bug.cgi?id=24896 . If the ia64 .dynsym STB_LOCAL symbols are not used by special relocations, it's likely a minor issue/missing improvement in ld's ia64 port. On 2022-12-09, Florian Weimer via Binutils wrote: >* Nick Clifton: > >> Hi Florian, >> >>> Is there a way to get the same effect on other targets? >> >> How are the loaders for other targets linked ? If they include the >> -X or --discard-locals option on the command line, then removing that >> option might achieve the result that you desire. > >I'm using: > > gcc -nostdlib -nostartfiles -shared -o …/build/elf/ld.so.new \ > -Wl,-z,relro -Wl,-z,defs \ > …/build/elf/librtld.os -Wl,--version-script=…/build/ld.map \ > -Wl,-soname=ld-linux-x86-64.so.2 > >gcc -v tells me: > >/usr/libexec/gcc/x86_64-redhat-linux/11/collect2 \ > -plugin /usr/libexec/gcc/x86_64-redhat-linux/11/liblto_plugin.so \ > -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper \ > -plugin-opt=-fresolution=/tmp/ccHaMg3U.res --build-id --no-add-needed \ > --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -shared \ > -o …/build/elf/ld.so.new -L/usr/lib/gcc/x86_64-redhat-linux/11 \ > -L/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64 -L/lib/../lib64 \ > -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/11/../../.. \ > -z relro -z defs …/build/elf/librtld.os --version-script=…/build/ld.map \ > -soname=ld-linux-x86-64.so.2 > >So it seems that -X or --discard-locals is the default? How do I >override that, preferably for specific symbols only? -X should be irrelevant for .dynsym entries. -X is not the default for almost all ports, but ld/emultempl/riscvelf.em has a hack to default to --discard-locals. That was copied by loongarch [Facepalm]. The proper way is to encode the logic in compiler drivers (I did this for Clang in https://reviews.llvm.org/D127826). >>> It would best >>> if I wouldn't have to bloat the entire symbol table for that. >> >> I don't think that you have symbol names without having entries in >> the symbol table. Although as you say, if they are local symbols >> then they will not also take up room in the GNU_HASH table. > >Yeah, should have said symbol hash table. I really want them in .dynsym >actually. > >Thanks, >Florian >