public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug inline-asm/98778] New: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 @ 2021-01-21 9:10 jbeulich at suse dot com 2021-01-21 11:36 ` [Bug inline-asm/98778] " jakub at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: jbeulich at suse dot com @ 2021-01-21 9:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98778 Bug ID: 98778 Summary: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: jbeulich at suse dot com Target Milestone: --- While in the example below all 3 variants get refused ("impossible constraint") with -fpic or with "-m32 -fpie", the ones in cases 0 and 2 get accepted with just -fpie, producing non-position-independent code (or more precisely unsuitable relocations). void efn(void); void(*efp)(void); void*test(int i) { void*res; switch(i) { case 0: asm("mov %1,%0" : "=r" (res) : "i" (test)); break; #ifndef __PIE__ case 1: asm("mov %1,%0" : "=r" (res) : "i" (efn)); break; #endif case 2: asm("mov %1,%0" : "=r" (res) : "i" (&efp)); break; default: res = (void*)0; break; } return res; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/98778] asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 2021-01-21 9:10 [Bug inline-asm/98778] New: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 jbeulich at suse dot com @ 2021-01-21 11:36 ` jakub at gcc dot gnu.org 2021-01-21 11:40 ` jakub at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2021-01-21 11:36 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98778 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I don't think anything guarantees that this should work. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/98778] asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 2021-01-21 9:10 [Bug inline-asm/98778] New: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 jbeulich at suse dot com 2021-01-21 11:36 ` [Bug inline-asm/98778] " jakub at gcc dot gnu.org @ 2021-01-21 11:40 ` jakub at gcc dot gnu.org 2021-01-21 12:27 ` jbeulich at suse dot com 2021-09-14 9:37 ` [Bug target/98778] " pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jakub at gcc dot gnu.org @ 2021-01-21 11:40 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98778 --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- In particular it is up to the inline asm writer to ensure that the result is PIC compatible through a wise choice of constraints etc. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/98778] asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 2021-01-21 9:10 [Bug inline-asm/98778] New: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 jbeulich at suse dot com 2021-01-21 11:36 ` [Bug inline-asm/98778] " jakub at gcc dot gnu.org 2021-01-21 11:40 ` jakub at gcc dot gnu.org @ 2021-01-21 12:27 ` jbeulich at suse dot com 2021-09-14 9:37 ` [Bug target/98778] " pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: jbeulich at suse dot com @ 2021-01-21 12:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98778 --- Comment #3 from jbeulich at suse dot com --- (In reply to Jakub Jelinek from comment #2) > In particular it is up to the inline asm writer to ensure that the result is > PIC compatible through a wise choice of constraints etc. Perhaps the description wasn't clear enough (but I think the title disambiguates it): I don't mean this to be made work. I'd expect an error on all three constructs, like with -fpic, rather than just on one of them. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/98778] asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 2021-01-21 9:10 [Bug inline-asm/98778] New: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 jbeulich at suse dot com ` (2 preceding siblings ...) 2021-01-21 12:27 ` jbeulich at suse dot com @ 2021-09-14 9:37 ` pinskia at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-09-14 9:37 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98778 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|inline-asm |target --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- else if (!SYMBOL_REF_FAR_ADDR_P (op0) && (SYMBOL_REF_LOCAL_P (op0) || (HAVE_LD_PIE_COPYRELOC && flag_pie && !SYMBOL_REF_WEAK (op0) && !SYMBOL_REF_FUNCTION_P (op0))) && ix86_cmodel != CM_LARGE_PIC) return true; Is why it is accepted. inside legitimate_pic_address_disp_p. SYMBOL_REF_LOCAL_P is true as it is defined in the TU for PIE case. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-14 9:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-01-21 9:10 [Bug inline-asm/98778] New: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 jbeulich at suse dot com 2021-01-21 11:36 ` [Bug inline-asm/98778] " jakub at gcc dot gnu.org 2021-01-21 11:40 ` jakub at gcc dot gnu.org 2021-01-21 12:27 ` jbeulich at suse dot com 2021-09-14 9:37 ` [Bug target/98778] " pinskia at gcc dot gnu.org
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).