On 02/27/2012 05:50 PM, Cristian Rodríguez wrote:
El 27/02/12 13:24, Cristian Rodríguez escribió:
El 27/02/12 09:53, Bernhard Voelker escribió:
In the GNU coreutils project, there was a discussion about a new test which uses a destructor in an *.so file loaded into program space via LD_PRELOAD:
http://lists.gnu.org/archive/html/coreutils/2012-02/msg00173.html
However, the destructor is not run on OpenSuSE (nor on SLES10.x btw.), but works fine on other systems (e.g. Redhat).
This is Jim's commit: http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=b29db6767612cf70e9...
Attached is the relevant C code which intercepts the system calls getxattr() and lgetxattr(). The number of calls is counted and should be stored in a file "x" by the destructor print_call_count():
void __attribute__ ((destructor)) print_call_count (void);
Compile / link it:
$ gcc -fPIC -O2 -c k.c $ ld -G k.o -o k.so
Works for me , I am in factory though.
# gcc -shared -rdynamic -march=native -Wall -fPIC $(rpm --eval %optflags) k.c -o k.so
LD_PRELOAD="./k.so" ls --color=always -l .
cat x --> 74
That works fine on 12.1 for me as well. ld -G is just not the right way to build a shared library, you should really use gcc -shared, Andreas -- Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg) GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org