From: Sam James <sam@gentoo.org>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Florian Weimer <fw@deneb.enyo.de>,
vapier@gentoo.org, "Andreas K. Huettel" <dilfridge@gentoo.org>,
libc-alpha@sourceware.org
Subject: Re: build failure on ia64 (+ patch), "relocation truncated to fit: GPREL22 against `.text'"
Date: Sun, 30 Jul 2023 14:27:48 +0100 [thread overview]
Message-ID: <87h6pl34v5.fsf@gentoo.org> (raw)
In-Reply-To: <2d78fafb-cba0-684f-d61b-c57b0e65d349@linaro.org>
Adhemerval Zanella Netto via Libc-alpha <libc-alpha@sourceware.org> writes:
> On 30/07/23 05:10, Florian Weimer wrote:
>> * Andreas K. Huettel via Libc-alpha:
>>
>>> diff --git a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
>>> index 3e4d5da820..eb7681b704 100644
>>> --- a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h
>>> @@ -32,7 +32,9 @@
>>> #ifndef __ASSEMBLER__
>>> /* Don't declare this as a function---we want it's entry-point, not
>>> it's function descriptor... */
>>> -extern int _dl_sysinfo_break attribute_hidden;
>>> +/* Use section ".text" to force far GPREL64 relocation instead of
>>> + GPREL22 . */
>>> +extern int _dl_sysinfo_break attribute_hidden __attribute__((section(".text")));
>>
>> More context:
>>
>> | /* Don't declare this as a function---we want it's entry-point, not
>> | it's function descriptor... */
>> | extern int _dl_sysinfo_break attribute_hidden;
>> | # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break)
>> | # define DL_SYSINFO_IMPLEMENTATION \
>> | asm (".text\n\t" \
>> | ".hidden _dl_sysinfo_break\n\t" \
>> | ".proc _dl_sysinfo_break\n\t" \
>> | "_dl_sysinfo_break:\n\t" \
>> | ".prologue\n\t" \
>> | ".altrp b6\n\t" \
>> | ".body\n\t" \
>> | "break 0x100000;\n\t" \
>> | "br.ret.sptk.many b6;\n\t" \
>> | ".endp _dl_sysinfo_break\n\t" \
>> | ".previous");
>> | #endif
>>
>> So this seems actually correct because the symbol is defined in .text.
>> (I was wondered why this would make .text writable.)
>
> That was my understanding back then as well, and I tested myself the testcase
> Sergei has created [1] and at least with gcc from 6 to 13 built with
> build-many-glibcs.py I don't see any relocation failure. But at same time
> I don't see any relocation failure with current code either, so I am not
> sure why this is happening with Gentoo toolchain (maybe a incomplete backport?).
I don't think we do much interesting there though. We had a user report
this again a few days ago with 13.
Our patchset at the moment is
https://gitweb.gentoo.org/proj/gcc-patches.git/tree/13.2.0/gentoo.
with
```
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ia64-unknown-linux-gnu/13/lto-wrapper
Target: ia64-unknown-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-13.2.0/work/gcc-13.2.0/configure --host=ia64-unknown-linux-gnu --build=ia64-unknown-linux-gnu --prefix=/usr --bindir=/usr/ia64-unknown-linux-gnu/gcc-bin/13 --includedir=/usr/lib/gcc/ia64-unknown-linux-gnu/13/include --datadir=/usr/share/gcc-data/ia64-unknown-linux-gnu/13 --mandir=/usr/share/gcc-data/ia64-unknown-linux-gnu/13/man --infodir=/usr/share/gcc-data/ia64-unknown-linux-gnu/13/info --with-gxx-include-dir=/usr/lib/gcc/ia64-unknown-linux-gnu/13/include/g++-v13 --with-python-dir=/share/gcc-data/ia64-unknown-linux-gnu/13/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 13.2.0 p3' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-fixed-point --enable-libgomp --disable-libssp --disable-libada --disable-cet --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --without-zstd --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.2.0 (Gentoo 13.2.0 p3)
```
>
> ---
> $ cat mk.bash
> #!/usr/bin/bash
>
> if [ $# -eq 0 ]; then
> echo "usage: mk.bash compiler"
> exit 0;
> fi
>
> CC=$1
>
> cat > conftest.c << EOF
> #ifdef USE_TEXT
> extern int asm_f __attribute__((visibility("hidden"))) __attribute__((section(".text")));
> #else
> extern int asm_f __attribute__((visibility("hidden")));
> #endif
>
> long asm_f_ref;
>
> asm (
> ".text\n\t" \
> ".hidden asm_f\n\t"
> ".proc asm_f\n\t"
> "asm_f:\n\t"
> ".prologue\n\t"
> ".body\n\t"
> "br.ret.sptk.many b0;\n\t"
> ".endp asm_f\n\t"
> ".previous"
> );
> EOF
>
> for define in "" "-DUSE_TEST"; do
> for static in "" "-static"; do
> for fpie in "" "-fPIE"; do
> for common in "-fcommon" "-fno-common"; do
> echo -n "define=${define} static=${static} common=${common} fpie=${fpie}: "
> $CC conftest.c -o a -O2 -nostdlib -nostartfiles -e asm_f_ref \
> ${static} ${define} ${fpie} ${common} 2>&1 >/dev/null
> if [ $? -eq 0 ]; then
> echo "OK"
> else
> echo "FAIL"
> fi
> done
> done
> done
> done
>
> rm conftest.c
> ---
>
>
> [1] https://sourceware.org/pipermail/libc-alpha/2020-May/114493.html
next prev parent reply other threads:[~2023-07-30 13:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-29 18:34 Andreas K. Huettel
2023-07-30 0:08 ` Adhemerval Zanella Netto
2023-07-30 0:15 ` Andreas K. Huettel
2023-07-30 8:10 ` Florian Weimer
2023-07-30 13:14 ` Adhemerval Zanella Netto
2023-07-30 13:27 ` Sam James [this message]
2023-07-30 14:03 ` Richard Henderson
2023-07-30 16:41 ` Alexander Monakov
2023-07-30 19:06 ` Adhemerval Zanella Netto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h6pl34v5.fsf@gentoo.org \
--to=sam@gentoo.org \
--cc=adhemerval.zanella@linaro.org \
--cc=dilfridge@gentoo.org \
--cc=fw@deneb.enyo.de \
--cc=libc-alpha@sourceware.org \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).