mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: Compilation error
Date: Mon, 8 Aug 2011 09:08:17 +0200	[thread overview]
Message-ID: <20110808070817.GD29562@port70.net> (raw)
In-Reply-To: <20110807220025.GL132@brightrain.aerifal.cx>

* Rich Felker <dalias@aerifal.cx> [2011-08-07 18:00:25 -0400]:
> > (for some reason dynamic linking with musl fails now if i
> > compile musl with pcc imho it used to work..)
> 
> Can you find where it fails?
> 

it can be a pcc bug
if i compile everything with pcc but link with gcc
then dynamic linking works

the only change to the linker flags is -L/path/to/pcclibs -lpcc
instead of -lgcc, so either pcc does not call ld properly
or there is some issue with -lpcc

pcc -v prints the way it calls the linker:
ld -v -X -shared -o lib/libc.so -e _start -Bsymbolic-functions -soname=libc.so [..src/*/*.lo..] -L/usr/local/lib/pcc/i686-pc-linux-gnu/1.1.0.DEVEL/lib/ -lpcc -g

i printed some variables right before do_single_reloc
(pcc debug info is not always reliable)
(type 8 is R_386_RELATIVE)


running in gdb:

type 8 sym_idex 0 reloc_addr 0xb785c37c *reloc_addr 0x8dc94 base 0xb77d1000 rel[0..2] 0x8b37c 0x8 0x8fdb4

Program received signal SIGSEGV, Segmentation fault.
0xb77ddda8 in do_single_reloc () at src/ldso/dynlink.c:148
148	}
(gdb) bt
#0  0xb77ddda8 in do_single_reloc () at src/ldso/dynlink.c:148
#1  0xb77ddcba in do_relocs (base=0xb77d1000 "\177ELF\001\001\001", start=<error type>, end=<error type>, 
    base=0xb77d1000 "\177ELF\001\001\001", start=<error type>, end=<error type>) at src/ldso/dynlink.c:146
#2  0xb77e048b in __dynlink () at src/ldso/dynlink.c:538
#3  0xb77e0abc in _start () from ../../lib/libc.so


running in valgrind:

type 8 sym_idex 0 reloc_addr 0x0408b37c *reloc_addr 0x8dc94 base 0x04000000 rel[0..2] 0x8b37c 0x8 0x8fdb4
==2261== 
==2261== Process terminating with default action of signal 11 (SIGSEGV)
==2261==  Bad permissions for mapped region at address 0x408B37C
==2261==    at 0x400CDA8: ??? (src/ldso/dynlink.c:148)
==2261==    by 0x400CCB9: ??? (src/ldso/dynlink.c:146)
==2261==    by 0x400F48A: __dynlink (src/ldso/dynlink.c:538)
==2261==    by 0x400FABB: (within /home/nsz/dev/lang/c/musl/lib/libc.so)


valgrind says it's permission problem so i printed smaps

smaps with pcc:

type 8 sym_idex 0 reloc_addr 0xb78ac1ec *reloc_addr 0x62544 base 0xb7863000 rel[0..2] 0x491ec 0x8 0x63000
...
b7862000-b7863000 r-xp b7862000 00:00 0          [vdso]
Size:                  4 kB
Rss:                   4 kB
Pss:                   0 kB
Shared_Clean:          4 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:            4 kB
Swap:                  0 kB
b7863000-b78c6000 r-xp 00000000 08:01 1581497    /home/nsz/dev/lang/c/musl/lib/libc.so
Size:                396 kB
Rss:                  68 kB
Pss:                  68 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:        68 kB
Private_Dirty:         0 kB
Referenced:           68 kB
Swap:                  0 kB
b78c6000-b78c7000 rwxp 00063000 08:01 1581497    /home/nsz/dev/lang/c/musl/lib/libc.so
Size:                  4 kB
Rss:                   4 kB
Pss:                   4 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         4 kB
Referenced:            4 kB
Swap:                  0 kB
...


smaps when linked with gcc (no segfault):

type 8 sym_idex 0 reloc_addr 0xb77c5ea4 *reloc_addr 0xdd40 base 0xb7760000 rel[0..2] 0x65ea4 0x8 0x65ea8
...
b775f000-b7760000 r-xp b775f000 00:00 0          [vdso]
Size:                  4 kB
Rss:                   4 kB
Pss:                   0 kB
Shared_Clean:          4 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:            4 kB
Swap:                  0 kB
b7760000-b77c5000 r-xp 00000000 08:01 5638271    /home/nsz/dev/lang/c/musl/lib/libc.so
Size:                404 kB
Rss:                  72 kB
Pss:                  72 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:        72 kB
Private_Dirty:         0 kB
Referenced:           72 kB
Swap:                  0 kB
b77c5000-b77c7000 rwxp 00064000 08:01 5638271    /home/nsz/dev/lang/c/musl/lib/libc.so
Size:                  8 kB
Rss:                   8 kB
Pss:                   8 kB
Shared_Clean:          0 kB
Shared_Dirty:          0 kB
Private_Clean:         0 kB
Private_Dirty:         8 kB
Referenced:            8 kB
Swap:                  0 kB
...


  parent reply	other threads:[~2011-08-08  7:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-07 18:57 nicolas
2011-08-07 19:36 ` Szabolcs Nagy
2011-08-07 19:34   ` Rich Felker
2011-08-07 19:50     ` Rich Felker
2011-08-07 21:01       ` nicolas
2011-08-07 20:52         ` Rich Felker
2011-08-07 22:09       ` Szabolcs Nagy
2011-08-07 22:00         ` Rich Felker
2011-08-07 22:05           ` Rich Felker
2011-08-08  7:08           ` Szabolcs Nagy [this message]
2011-08-17 10:33             ` Szabolcs Nagy
2011-08-17 13:39               ` Rich Felker
2011-08-17 14:47                 ` Szabolcs Nagy
2011-08-17 14:59                   ` Szabolcs Nagy
2011-08-17 18:18                   ` Rich Felker
2011-08-08 13:03           ` Make nicolas
2011-08-08 20:55             ` Make Rich Felker
2011-08-08 20:56             ` Make Rich Felker
2011-08-09 19:10               ` Make nicolas
2011-08-09 19:29                 ` Make Rich Felker
2011-08-09 20:23                 ` Make Szabolcs Nagy
2011-08-10 19:19                   ` Make nicolas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110808070817.GD29562@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).