Ian Wienand: What exactly does -Bsymblic do? -- update
Some time ago I wrote a description of the -Bsymbolic
linker flag which could do with some further explanation. The original
article is a good starting place.
One interesting point that I didn't go into was the potential for
code optimisation -Bsymbolic brings about. I'm not sure if I
missed that at the time, or the toolchain changed, both are probably
equally likely!
Let me recap the example...
In words; libtest.so provides test_foo(), which
calls foo() to do the actual work.
libtest-bsymbolic.so is simply built with the flag in
question, -Bsymbolic. liboverride.so provides the
alternative version of foo() designed to override the
original via a LD_PRELOAD of the library.
test is built against libtest.so,
test-bsymbolic against libtest-bsymbolic.so.
Running the examples, we can see that the LD_PRELOAD does
not override the symbol in the library built with
-Bsymbolic.
There are a couple of things going on here. Firstly, you can see
that the SYMBOLIC flag is set in the dynamic section, leading to the
dynamic linker behaviour I explained in the original
article:
However, there is also an effect on generated code. Have a look at
the PLTs:
Notice the difference? There is no PLT entry for foo()
when -Bsymbolic is used.
Effectively, the toolchain has noticed that foo() can
never be overridden and optimised out the PLT call for it. This is
analogous to using "hidden" attributes for symbols, which I have
detailed in another article on symbol
visiblity attributes (which also goes into PLT's, if the above
meant nothing to you).
So -Bsymbolic does have some more side-effects than just
setting a flag to tell the dynamic linker about binding rules -- it
can actually result in optimised code. However, I'm still struggling
to find good use-cases for -Bsymbolic that can't be better
done with Version scripts and visibility attributes. I would
certainly recommend using these methods if at all possible.
Thanks to Ryan Lortie for comments on the original article.
ianw@jj:/tmp/bsymbolic$ cat Makefile
all: test test-bsymbolic
clean:
rm -f *.so test testsym
liboverride.so : liboverride.c
$(CC) -Wall -O2 -shared -fPIC -o liboverride.so $<
libtest.so : libtest.c
$(CC) -Wall -O2 -shared -fPIC -o libtest.so $<
libtest-bsymbolic.so : libtest.c
$(CC) -Wall -O2 -shared -fPIC -Wl,-Bsymbolic -o $@ $<
test : test.c libtest.so liboverride.so
$(CC) -Wall -O2 -L. -Wl,-rpath=. -ltest -o $@ $<
test-bsymbolic : test.c libtest-bsymbolic.so liboverride.so
$(CC) -Wall -O2 -L. -Wl,-rpath=. -ltest-bsymbolic -o $@ $<
$ cat liboverride.c
#include <stdio.h>
int foo(void)
printf("override foo called\n");
return 0;
$ cat libtest.c
#include <stdio.h>
int foo(void)
printf("libtest foo called\n");
return 1;
int test_foo(void)
return foo();
$ cat test.c
#include <stdio.h>
int test_foo(void);
int main(void)
printf("%d\n", test_foo());
return 0;
$ ./test libtest foo called 1 $ ./test-bsymbolic libtest foo called 1 $ LD_PRELOAD=liboverride.so ./test override foo called 0 $ LD_PRELOAD=liboverride.so ./test-bsymbolic libtest foo called 1
ianw@jj:/tmp/bsymbolic$ readelf --dynamic ./libtest-bsymbolic.so Dynamic section at offset 0x550 contains 22 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [libc.so.6] 0x00000010 (SYMBOLIC) 0x0 ...
$ objdump --disassemble-all ./libtest.so Disassembly of section .plt: [... blah ...] 0000039c <foo>: 39c: ff a3 10 00 00 00 jmp *0x10(%ebx) 3a2: 68 08 00 00 00 push $0x8 3a7: e9 d0 ff ff ff jmp 37c <_init+0x30>
$ objdump --disassemble-all ./libtest-bsymbolic.so
Disassembly of section .plt:
00000374 <__gmon_start__@plt-0x10>:
374: ff b3 04 00 00 00 pushl 0x4(%ebx)
37a: ff a3 08 00 00 00 jmp *0x8(%ebx)
380: 00 00 add %al,(%eax)
...
00000384 <__gmon_start__@plt>:
384: ff a3 0c 00 00 00 jmp *0xc(%ebx)
38a: 68 00 00 00 00 push $0x0
38f: e9 e0 ff ff ff jmp 374 <_init+0x30>
00000394 <puts>:
394: ff a3 10 00 00 00 jmp *0x10(%ebx)
39a: 68 08 00 00 00 push $0x8
39f: e9 d0 ff ff ff jmp 374 <_init+0x30>
000003a4 <__cxa_finalize@plt>:
3a4: ff a3 14 00 00 00 jmp *0x14(%ebx)
3aa: 68 10 00 00 00 push $0x10
3af: e9 c0 ff ff ff jmp 374 <_init+0x30>
The annual
Dear New Yorkers,
I'm going to speak at Free Culture NYU about my current project,
Today is the last day of this conference, which has been a great experience of interaction between Central America and Caribbean communities. Yesterday we had packaging, BTS, kernel, pbuilder and quilt related talks. We also expanded the web of trust with a key signing party with almost 30 participants. Even a BoF about people interested in VoIP was held before going downtown to share some beers :)
We haven t done much work on keeping the continuous integration (CI) machines online, and there haven t been any new builds since November of 09. I should set Nagios to remind us when things get off track or something. The recent acceptance of the DLR into Debian and our intention to get the next release produced has inspired me (and maybe others) to get things back up.
Sitting at my hotel room in Tijuana, about to hit the bed, quite tired because of a nice, long walk I will write more about tomorrow, I have been listening for at least five minutes to a long, stupid infomerciative spam in the History Channel: A fountain pen, a five-point pen, and three other pen-like implements (plus extra and extra and extra things... They are listing a case with 63 implements now!)
Now, what is the hook into getting somebody to call for a classy pen? Elegance, of course! Just for the sake of this exercise, the spam continues to be played. And yes, it's only been two short paragraphs. But believe me, I am very tired, and trying to get some coherent English out of my brain is not as easy as it could.
Elegance, I said, right? Good. How do you convey elegance to TV spam/infomercials? Well, what's more classy and refined than a 30 second sample of Haydn? Man, Haydn is *so* classy that the viewer will not even notice the snippets of blabber have incoherent redaction.
Anyway... Spam goes on. I cannot stand any more repetitions of this 30 Haydn seconds. They are stronger than me. And that old lady says that anybody is writing in their computer now I will only write with my fountain pen from now on! I will surely follow her wise advise!
(STOP IT WITH THE STUPID HORN!)
Not only fixes ipconfig regressions due to fixes in 1.5.16, but ipconfig should no longer discard useful packages. We also fixed a long standing klibc sparc specific socket bug (
Well here it is, the last shot in the challenge. I've quite enjoyed it this week, I post a follow-up over the weekend with some more thoughts but for now the last image...


Note: Please see
The movie ' Fight Club' had a profound effect on me when I first saw it in
1999. I wasn't as fond of the originating novel, although there was something
about the prose that Palahniuk used which I did enjoy.
Since then I've read more of Palahniuk's work. My favourite of his books is
actually Non-Fiction (a.k.a. Stranger than Fiction ): a collection of
essays and interviews. Reading some of the stories in that collection, it
becomes very clear where some of the concepts in his fiction originate. There
are also a number of pieces on the craft of writing. He writes some really
gushing praise about Amy Hempel:
The following is an invitation to the Latvian Ubuntu Bug Jam (in Latvian) sent for a bit of a wider circulation to catch people that monitor 