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  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 <>
To:	Andi Kleen <>, "H. Peter Anvin" <>,
	Ian Lance Taylor <>,
	Mathieu Desnoyers <>
Subject: Userspace Tracepoints, -fPIC -m32 question


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.



----- Forwarded message from Pierre-Marc Fournier <> -----

Date: Mon, 09 Nov 2009 16:23:10 -0500
To: Mathieu Desnoyers <>
User-Agent: Mozilla-Thunderbird (X11/20090701)
From: Pierre-Marc Fournier <>
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

- 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?




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

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"
             :: [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
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists