From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fw@deneb.enyo.de>,
"Andreas K. Huettel via Libc-alpha" <libc-alpha@sourceware.org>
Cc: vapier@gentoo.org, "Andreas K. Huettel" <dilfridge@gentoo.org>
Subject: Re: build failure on ia64 (+ patch), "relocation truncated to fit: GPREL22 against `.text'"
Date: Sun, 30 Jul 2023 10:14:15 -0300 [thread overview]
Message-ID: <2d78fafb-cba0-684f-d61b-c57b0e65d349@linaro.org> (raw)
In-Reply-To: <87leex250z.fsf@mid.deneb.enyo.de>
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?).
---
$ 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:14 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 [this message]
2023-07-30 13:27 ` Sam James
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=2d78fafb-cba0-684f-d61b-c57b0e65d349@linaro.org \
--to=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).