lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 9 Nov 2009 18:38:42 -0500
From:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
To:	Andi Kleen <andi@...stfloor.org>, "H. Peter Anvin" <hpa@...or.com>,
	Ian Lance Taylor <iant@...gle.com>, gcc-help@....gnu.org
Cc:	linux-kernel@...r.kernel.org, rostedt@...dmis.org,
	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Subject: Userspace Tracepoints, -fPIC -m32 question

Hi,

I've been looking into the problem explained below for a while, and have
a hard time figuring out if it is actually possible to pass a C pointer
as gcc inline assembly immediate operand in a way that works with -fPIC
on 32-bit i386. It works fine for x86_64 (both with and w/o -fPIC) and
with 32-bit i386 w/o fPIC.

The problem on 32-bit i386 with fPIC is that the assembly generated
should contain a GOTOFF relocation because the address seems to be
treated as a global symbol. e.g., using a "m" (var) operand turns the
code presented in the forwarded message (below) into:

        .long var.1195@...OFF(%ecx), (1f)

Ideas and comments would be very welcome.

Thanks,

Mathieu

----- Forwarded message from Pierre-Marc Fournier <pierre-marc.fournier@...ymtl.ca> -----

Date: Mon, 09 Nov 2009 16:23:10 -0500
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701)
From: Pierre-Marc Fournier <pierre-marc.fournier@...ymtl.ca>
Subject: Questions about position-independent  code

Hi Mathieu,

Perhaps you can help with an issue I have concerning
position-independent code on x86. Or maybe you know someone who could help.

Consider the code below. It compiles perfectly well on x86-64 with or
without -fPIC.

However, on x86-32, it compiles only when the -fPIC option is not
specified. Otherwise, gcc gives the following error:

immprob.c: In function 'func':
immprob.c:15: warning: asm operand 0 probably doesn't match constraints
immprob.c:15: error: impossible constraint in 'asm'


My questions:
- Is it important to generated PIC code for libraries on x86-32? It
seems to work perfectly well to make them as non-PIC. Libtool on my
system does however put the -fPIC flag to gcc when building libraries on
x86-32.

- Assuming it is important to make PIC libraries on x86-32, can I get
the address of "var" to be but statically in the __my_section section on
this architecture?

Thanks

pmf

---

#if x86_64
#define _ASM_PTR ".quad "
#else
#define _ASM_PTR ".long "
#endif

struct mystruct {
	int myint;
};

int func()
{
        static struct mystruct var __attribute__((section("mysec2")))
		= { 0 };

        asm (".section __my_section,\"aw\",@progbits\n\t"
             _ASM_PTR "%c[addr], (1f)\n\t"
             ".previous\n\t"
             "1:\n\t"
             :: [addr] "i" (&var)
        );

        return 0;
}

	

----- End forwarded message -----

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ