编译glibc遇到的问题

因为学习堆的时候需要glibc2.26以下的版本,决定自己在docker里编译一个glibc2.24,中间遇到一些bug记录如下

.symver on common symbols

编译时报错

1
2
3
/tmp/ccPRCqlU.s: Error: `loc1@GLIBC_2.2.5' can't be versioned to common symbol 'loc1'
/tmp/ccPRCqlU.s: Error: `loc2@GLIBC_2.2.5' can't be versioned to common symbol 'loc2'
/tmp/ccPRCqlU.s: Error: `locs@GLIBC_2.2.5' can't be versioned to common symbol 'locs'

解决方案:https://patchwork.ozlabs.org/patch/780067/
patch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--- a/misc/regexp.c
+++ b/misc/regexp.c
@@ -29,14 +29,15 @@

#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)

-/* Define the variables used for the interface. */
-char *loc1;
-char *loc2;
+/* Define the variables used for the interface. Avoid .symver on common
+ symbol, which just creates a new common symbol, not an alias. */
+char *loc1 __attribute__ ((nocommon));
+char *loc2 __attribute__ ((nocommon));
compat_symbol (libc, loc1, loc1, GLIBC_2_0);
compat_symbol (libc, loc2, loc2, GLIBC_2_0);

/* Although we do not support the use we define this variable as well. */
-char *locs;
+char *locs __attribute__ ((nocommon));
compat_symbol (libc, locs, locs, GLIBC_2_0);

target ‘/root/build/math/e_pow.o’ failed

报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
../sysdeps/ieee754/dbl-64/e_pow.c:469:13: error: ‘<<’ in boolean context, did you mean ‘<’ ? [-Werror=int-in-bool-context]
if (n << (k - 20))
~~^~~~~~~~~~~
../sysdeps/ieee754/dbl-64/e_pow.c:471:17: error: ‘<<’ in boolean context, did you mean ‘<’ ? [-Werror=int-in-bool-context]
return (n << (k - 21)) ? -1 : 1;
~~~^~~~~~~~~~~~
../sysdeps/ieee754/dbl-64/e_pow.c:477:9: error: ‘<<’ in boolean context, did you mean ‘<’ ? [-Werror=int-in-bool-context]
if (m << (k + 12))
~~^~~~~~~~~~~
../sysdeps/ieee754/dbl-64/e_pow.c:479:13: error: ‘<<’ in boolean context, did you mean ‘<’ ? [-Werror=int-in-bool-context]
return (m << (k + 11)) ? -1 : 1;
~~~^~~~~~~~~~~~

解决方案: https://patchwork.ozlabs.org/patch/680578/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
diff --git a/sysdeps/ieee754/dbl-64/e_pow.c b/sysdeps/ieee754/dbl-64/e_pow.c
index 663fa39..bd758b5 100644
--- a/!
+++ b/sysdeps/ieee754/dbl-64/e_pow.c
@@ -466,15 +466,15 @@ checkint (double x)
return (n & 1) ? -1 : 1; /* odd or even */
if (k > 20)
{
- if (n << (k - 20))
+ if (n << (k - 20) != 0)
return 0; /* if not integer */
- return (n << (k - 21)) ? -1 : 1;
+ return (n << (k - 21) != 0) ? -1 : 1;
}
if (n)
return 0; /*if not integer */
if (k == 20)
return (m & 1) ? -1 : 1;
- if (m << (k + 12))
+ if (m << (k + 12) != 0)
return 0;
- return (m << (k + 11)) ? -1 : 1;
+ return (m << (k + 11) != 0) ? -1 : 1;
}

sunrpc/rpc_parse.c

1
2
3
4
5
6
7
8
9
rpc_parse.c:543:23: error: ‘%d’ directive writing between 1 and 10 bytes into a region of size 7 [-Werror=format-overflow=]
sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
^~
rpc_parse.c:543:20: note: directive argument in the range [1, 2147483647]
sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
^~~~~~
rpc_parse.c:543:5: note: ‘sprintf’ output between 5 and 14 bytes into a destination of size 10
sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

解决方案:

1
2
3
4
5
6
7
8
--- a/sunrpc/rpc_parse.c
+++ b/sunrpc/rpc_parse.c
@@ -521,7 +521,7 @@ static void
get_prog_declaration (declaration * dec, defkind dkind, int num /* arg number */ )
{
token tok;
- char name[10]; /* argument name */
+ char name[MAXLINESIZE]; /* argument name */

nis/nss_nisplus/nisplus-alias.c

1
2
3
4
5
6
nss_nisplus/nisplus-alias.c:300:12: error: argument 1 null where non-null expected [-Werror=nonnull]
[ERROR] nss_nisplus/nisplus-alias.c:303:39: error: '%s' directive argument is null [-Werror=format-truncation=]
[ERROR] make[3]: *** [/Volumes/OSXElCapitan/Users/mrdekk/casesafe/.build/x86_64-ubuntu16.04-linux-gnu/build/build-libc-final/multilib/nis/nisplus-alias.os] Error 1
[ERROR] make[3]: *** Waiting for unfinished jobs....
[ERROR] make[2]: *** [nis/others] Error 2
[ERROR] make[1]: *** [all] Error 2

解决方案:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c
index 7f698b4e6d..509ace1f83 100644
--- a/nis/nss_nisplus/nisplus-alias.c
+++ b/nis/nss_nisplus/nisplus-alias.c
@@ -297,10 +297,10 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias,
return NSS_STATUS_UNAVAIL;
}

- char buf[strlen (name) + 9 + tablename_len];
+ char buf[tablename_len + 9];
int olderr = errno;

- snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val);
+ snprintf (buf, sizeof (buf), "[name=],%s", tablename_val);

build目录缺少/etc/ld.so.conf

解决方案:

1
2
cd /etc/
touch ld.so.conf

文章目录
  1. 1. .symver on common symbols
  2. 2. target ‘/root/build/math/e_pow.o’ failed
  3. 3. sunrpc/rpc_parse.c
  4. 4. nis/nss_nisplus/nisplus-alias.c
  5. 5. build目录缺少/etc/ld.so.conf
|