Gentoo Archives: gentoo-musl

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-musl@l.g.o
Subject: Re: [gentoo-musl] What is crtbeginP.o ?
Date: Fri, 10 Jun 2016 12:49:34
Message-Id: c5df73c3-f1a7-e22b-f5ff-1b040bf7bd4d@gentoo.org
In Reply to: Re: [gentoo-musl] What is crtbeginP.o ? by Lei Zhang
1 On 6/10/16 7:56 AM, Lei Zhang wrote:
2 > 2016-06-10 17:15 GMT+08:00 Anthony G. Basile <blueness@g.o>:
3 >> so i recommend you play with different gcc compiler profiles using
4 >> gcc-config on the musl based system you built with GRS, and look at the
5 >> collect2 line to see which end files are deployed with each setting.
6 >> then i recommend trying to read the gcc spec file for each of the
7 >> compiler profiles. then if you know some assembly, look at the code for
8 >> those end files which you can find in the musl source tree. that'll
9 >> give you some idea what's going on there.
10 >
11 > Below are my findings after some experimentation:
12 >
13 > crt files linked by default, on my glibc based host:
14 > crt1.o crti.o crtn.o
15 > crtbegin.o crtend.o
16 >
17 > with "-static":
18 > crt1.o crti.o crtn.o
19 > crtbeginT.o crtend.o
20 >
21 > with "-shared":
22 > crti.o crtn.o
23 > crtbeginS.o crtendS.o
24 >
25 > This complies with what is written on this page:
26 > https://dev.gentoo.org/~vapier/crt.txt
27 >
28 > Things are a bit different on the musl based system. By default:
29 > Scrt1.o crti.o crtn.o
30 > crtbeginS.o crtendS.o
31 >
32 > with "-static":
33 > Scrt1.o crti.o crtn.o
34 > crtbeginP.o crtendS.o
35 >
36 > with "-shared":
37 > crti.o crtn.o
38 > crtbeginS.o crtendS.o
39 >
40 > This looks like a bit of mess to me...
41
42 No, the difference is not glibc vs musl, the difference is non-hardened
43 vs hardened.
44
45 >
46 > To make it even more confusing, I also found that on the glibc based
47 > system, crtend.o and crtendS.o are the same; on the musl one,
48 > crtbegin.o is the same as crtbeginT.o, and crtbeginP.o is the same as
49 > crtbeginS.o.
50 >
51 >
52 > Lei
53 >
54
55
56 --
57 Anthony G. Basile, Ph.D.
58 Gentoo Linux Developer [Hardened]
59 E-Mail : blueness@g.o
60 GnuPG FP : 1FED FAD9 D82C 52A5 3BAB DC79 9384 FA6E F52D 4BBA
61 GnuPG ID : F52D4BBA