100-musl-compat.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. https://sourceware.org/bugzilla/show_bug.cgi?id=21002
  2. --- a/lib/system.h
  3. +++ b/lib/system.h
  4. @@ -140,6 +140,19 @@ pread_retry (int fd, void *buf, size_t l
  5. return recvd;
  6. }
  7. +#ifdef HAVE_ERROR_H
  8. +#include "error.h"
  9. +#else
  10. +#include "err.h"
  11. +#define error(status, errno, ...) \
  12. + fflush(stdout); \
  13. + warn(__VA_ARGS__); \
  14. + if (status) exit(status)
  15. +#endif
  16. +
  17. +#ifndef __GLIBC__
  18. +#define canonicalize_file_name(name) realpath(name,NULL)
  19. +#endif
  20. /* We need define two variables, argp_program_version_hook and
  21. argp_program_bug_address, in all programs. argp.h declares these
  22. --- a/lib/color.c
  23. +++ b/lib/color.c
  24. @@ -32,12 +32,12 @@
  25. #endif
  26. #include <argp.h>
  27. -#include <error.h>
  28. #include <libintl.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <unistd.h>
  32. #include "libeu.h"
  33. +#include "system.h"
  34. /* Prototype for option handler. */
  35. --- a/lib/xmalloc.c
  36. +++ b/lib/xmalloc.c
  37. @@ -30,7 +30,6 @@
  38. # include <config.h>
  39. #endif
  40. -#include <error.h>
  41. #include <libintl.h>
  42. #include <stddef.h>
  43. #include <stdlib.h>
  44. --- a/src/addr2line.c
  45. +++ b/src/addr2line.c
  46. @@ -23,7 +23,6 @@
  47. #include <argp.h>
  48. #include <assert.h>
  49. #include <errno.h>
  50. -#include <error.h>
  51. #include <fcntl.h>
  52. #include <inttypes.h>
  53. #include <libdwfl.h>
  54. --- a/src/ar.c
  55. +++ b/src/ar.c
  56. @@ -22,7 +22,6 @@
  57. #include <argp.h>
  58. #include <assert.h>
  59. -#include <error.h>
  60. #include <fcntl.h>
  61. #include <gelf.h>
  62. #include <libintl.h>
  63. --- a/src/arlib2.c
  64. +++ b/src/arlib2.c
  65. @@ -20,7 +20,6 @@
  66. # include <config.h>
  67. #endif
  68. -#include <error.h>
  69. #include <libintl.h>
  70. #include <limits.h>
  71. #include <string.h>
  72. --- a/src/arlib.c
  73. +++ b/src/arlib.c
  74. @@ -21,7 +21,6 @@
  75. #endif
  76. #include <assert.h>
  77. -#include <error.h>
  78. #include <gelf.h>
  79. #include <inttypes.h>
  80. #include <libintl.h>
  81. --- a/src/elfcmp.c
  82. +++ b/src/elfcmp.c
  83. @@ -23,7 +23,6 @@
  84. #include <argp.h>
  85. #include <assert.h>
  86. #include <errno.h>
  87. -#include <error.h>
  88. #include <fcntl.h>
  89. #include <locale.h>
  90. #include <libintl.h>
  91. --- a/src/elflint.c
  92. +++ b/src/elflint.c
  93. @@ -24,7 +24,6 @@
  94. #include <assert.h>
  95. #include <byteswap.h>
  96. #include <endian.h>
  97. -#include <error.h>
  98. #include <fcntl.h>
  99. #include <gelf.h>
  100. #include <inttypes.h>
  101. --- a/src/findtextrel.c
  102. +++ b/src/findtextrel.c
  103. @@ -23,7 +23,6 @@
  104. #include <argp.h>
  105. #include <assert.h>
  106. #include <errno.h>
  107. -#include <error.h>
  108. #include <fcntl.h>
  109. #include <gelf.h>
  110. #include <libdw.h>
  111. --- a/src/nm.c
  112. +++ b/src/nm.c
  113. @@ -26,7 +26,6 @@
  114. #include <ctype.h>
  115. #include <dwarf.h>
  116. #include <errno.h>
  117. -#include <error.h>
  118. #include <fcntl.h>
  119. #include <gelf.h>
  120. #include <inttypes.h>
  121. --- a/src/objdump.c
  122. +++ b/src/objdump.c
  123. @@ -21,7 +21,6 @@
  124. #endif
  125. #include <argp.h>
  126. -#include <error.h>
  127. #include <fcntl.h>
  128. #include <inttypes.h>
  129. #include <libintl.h>
  130. --- a/src/ranlib.c
  131. +++ b/src/ranlib.c
  132. @@ -24,7 +24,6 @@
  133. #include <argp.h>
  134. #include <assert.h>
  135. #include <errno.h>
  136. -#include <error.h>
  137. #include <fcntl.h>
  138. #include <gelf.h>
  139. #include <libintl.h>
  140. --- a/src/readelf.c
  141. +++ b/src/readelf.c
  142. @@ -25,7 +25,6 @@
  143. #include <ctype.h>
  144. #include <dwarf.h>
  145. #include <errno.h>
  146. -#include <error.h>
  147. #include <fcntl.h>
  148. #include <gelf.h>
  149. #include <inttypes.h>
  150. --- a/src/size.c
  151. +++ b/src/size.c
  152. @@ -21,7 +21,6 @@
  153. #endif
  154. #include <argp.h>
  155. -#include <error.h>
  156. #include <fcntl.h>
  157. #include <gelf.h>
  158. #include <inttypes.h>
  159. --- a/src/stack.c
  160. +++ b/src/stack.c
  161. @@ -18,7 +18,6 @@
  162. #include <config.h>
  163. #include <assert.h>
  164. #include <argp.h>
  165. -#include <error.h>
  166. #include <stdlib.h>
  167. #include <inttypes.h>
  168. #include <stdio.h>
  169. --- a/src/strings.c
  170. +++ b/src/strings.c
  171. @@ -25,7 +25,6 @@
  172. #include <ctype.h>
  173. #include <endian.h>
  174. #include <errno.h>
  175. -#include <error.h>
  176. #include <fcntl.h>
  177. #include <gelf.h>
  178. #include <inttypes.h>
  179. --- a/src/strip.c
  180. +++ b/src/strip.c
  181. @@ -24,7 +24,6 @@
  182. #include <assert.h>
  183. #include <byteswap.h>
  184. #include <endian.h>
  185. -#include <error.h>
  186. #include <fcntl.h>
  187. #include <gelf.h>
  188. #include <libelf.h>
  189. --- a/src/unstrip.c
  190. +++ b/src/unstrip.c
  191. @@ -31,7 +31,6 @@
  192. #include <argp.h>
  193. #include <assert.h>
  194. #include <errno.h>
  195. -#include <error.h>
  196. #include <fcntl.h>
  197. #include <fnmatch.h>
  198. #include <libintl.h>
  199. --- a/tests/addrscopes.c
  200. +++ b/tests/addrscopes.c
  201. @@ -25,7 +25,6 @@
  202. #include <stdio_ext.h>
  203. #include <locale.h>
  204. #include <stdlib.h>
  205. -#include <error.h>
  206. #include <string.h>
  207. --- a/tests/allregs.c
  208. +++ b/tests/allregs.c
  209. @@ -21,7 +21,6 @@
  210. #include <stdio.h>
  211. #include <stdlib.h>
  212. #include <string.h>
  213. -#include <error.h>
  214. #include <locale.h>
  215. #include <argp.h>
  216. #include <assert.h>
  217. --- a/tests/backtrace.c
  218. +++ b/tests/backtrace.c
  219. @@ -24,7 +24,6 @@
  220. #include <dirent.h>
  221. #include <stdlib.h>
  222. #include <errno.h>
  223. -#include <error.h>
  224. #include <unistd.h>
  225. #include <dwarf.h>
  226. #ifdef __linux__
  227. --- a/tests/backtrace-data.c
  228. +++ b/tests/backtrace-data.c
  229. @@ -27,7 +27,6 @@
  230. #include <dirent.h>
  231. #include <stdlib.h>
  232. #include <errno.h>
  233. -#include <error.h>
  234. #include <unistd.h>
  235. #include <dwarf.h>
  236. #if defined(__x86_64__) && defined(__linux__)
  237. --- a/tests/buildid.c
  238. +++ b/tests/buildid.c
  239. @@ -23,7 +23,6 @@
  240. #include ELFUTILS_HEADER(elf)
  241. #include ELFUTILS_HEADER(dwelf)
  242. #include <stdio.h>
  243. -#include <error.h>
  244. #include <string.h>
  245. #include <stdlib.h>
  246. #include <sys/types.h>
  247. --- a/tests/debugaltlink.c
  248. +++ b/tests/debugaltlink.c
  249. @@ -23,7 +23,6 @@
  250. #include ELFUTILS_HEADER(dw)
  251. #include ELFUTILS_HEADER(dwelf)
  252. #include <stdio.h>
  253. -#include <error.h>
  254. #include <string.h>
  255. #include <stdlib.h>
  256. #include <sys/types.h>
  257. --- a/tests/debuglink.c
  258. +++ b/tests/debuglink.c
  259. @@ -21,7 +21,6 @@
  260. #include <errno.h>
  261. #include ELFUTILS_HEADER(dwelf)
  262. #include <stdio.h>
  263. -#include <error.h>
  264. #include <string.h>
  265. #include <stdlib.h>
  266. #include <sys/types.h>
  267. --- a/tests/dwfl-addr-sect.c
  268. +++ b/tests/dwfl-addr-sect.c
  269. @@ -23,7 +23,6 @@
  270. #include <stdio_ext.h>
  271. #include <stdlib.h>
  272. #include <string.h>
  273. -#include <error.h>
  274. #include <locale.h>
  275. #include <argp.h>
  276. #include ELFUTILS_HEADER(dwfl)
  277. --- a/tests/dwfl-bug-addr-overflow.c
  278. +++ b/tests/dwfl-bug-addr-overflow.c
  279. @@ -20,7 +20,6 @@
  280. #include <inttypes.h>
  281. #include <stdio.h>
  282. #include <stdio_ext.h>
  283. -#include <error.h>
  284. #include <locale.h>
  285. #include ELFUTILS_HEADER(dwfl)
  286. --- a/tests/dwfl-bug-fd-leak.c
  287. +++ b/tests/dwfl-bug-fd-leak.c
  288. @@ -24,7 +24,6 @@
  289. #include <dirent.h>
  290. #include <stdlib.h>
  291. #include <errno.h>
  292. -#include <error.h>
  293. #include <unistd.h>
  294. #include <dwarf.h>
  295. --- a/tests/dwfl-bug-getmodules.c
  296. +++ b/tests/dwfl-bug-getmodules.c
  297. @@ -18,7 +18,6 @@
  298. #include <config.h>
  299. #include ELFUTILS_HEADER(dwfl)
  300. -#include <error.h>
  301. static const Dwfl_Callbacks callbacks =
  302. {
  303. --- a/tests/dwfllines.c
  304. +++ b/tests/dwfllines.c
  305. @@ -27,7 +27,6 @@
  306. #include <stdio.h>
  307. #include <stdlib.h>
  308. #include <string.h>
  309. -#include <error.h>
  310. int
  311. main (int argc, char *argv[])
  312. --- a/tests/dwflmodtest.c
  313. +++ b/tests/dwflmodtest.c
  314. @@ -23,7 +23,6 @@
  315. #include <stdio_ext.h>
  316. #include <stdlib.h>
  317. #include <string.h>
  318. -#include <error.h>
  319. #include <locale.h>
  320. #include <argp.h>
  321. #include ELFUTILS_HEADER(dwfl)
  322. --- a/tests/dwfl-report-elf-align.c
  323. +++ b/tests/dwfl-report-elf-align.c
  324. @@ -20,7 +20,6 @@
  325. #include <inttypes.h>
  326. #include <stdio.h>
  327. #include <stdio_ext.h>
  328. -#include <error.h>
  329. #include <locale.h>
  330. #include <string.h>
  331. #include <stdlib.h>
  332. --- a/tests/dwflsyms.c
  333. +++ b/tests/dwflsyms.c
  334. @@ -25,7 +25,6 @@
  335. #include <stdio.h>
  336. #include <stdio_ext.h>
  337. #include <stdlib.h>
  338. -#include <error.h>
  339. #include <string.h>
  340. static const char *
  341. --- a/tests/early-offscn.c
  342. +++ b/tests/early-offscn.c
  343. @@ -19,7 +19,6 @@
  344. #endif
  345. #include <errno.h>
  346. -#include <error.h>
  347. #include <fcntl.h>
  348. #include <gelf.h>
  349. #include <stdio.h>
  350. --- a/tests/ecp.c
  351. +++ b/tests/ecp.c
  352. @@ -20,7 +20,6 @@
  353. #endif
  354. #include <errno.h>
  355. -#include <error.h>
  356. #include <fcntl.h>
  357. #include <gelf.h>
  358. #include <stdlib.h>
  359. --- a/tests/find-prologues.c
  360. +++ b/tests/find-prologues.c
  361. @@ -25,7 +25,6 @@
  362. #include <stdio_ext.h>
  363. #include <locale.h>
  364. #include <stdlib.h>
  365. -#include <error.h>
  366. #include <string.h>
  367. #include <fnmatch.h>
  368. --- a/tests/funcretval.c
  369. +++ b/tests/funcretval.c
  370. @@ -25,7 +25,6 @@
  371. #include <stdio_ext.h>
  372. #include <locale.h>
  373. #include <stdlib.h>
  374. -#include <error.h>
  375. #include <string.h>
  376. #include <fnmatch.h>
  377. --- a/tests/funcscopes.c
  378. +++ b/tests/funcscopes.c
  379. @@ -25,7 +25,6 @@
  380. #include <stdio_ext.h>
  381. #include <locale.h>
  382. #include <stdlib.h>
  383. -#include <error.h>
  384. #include <string.h>
  385. #include <fnmatch.h>
  386. --- a/tests/line2addr.c
  387. +++ b/tests/line2addr.c
  388. @@ -26,7 +26,6 @@
  389. #include <locale.h>
  390. #include <stdlib.h>
  391. #include <string.h>
  392. -#include <error.h>
  393. static void
  394. --- a/tests/low_high_pc.c
  395. +++ b/tests/low_high_pc.c
  396. @@ -25,7 +25,6 @@
  397. #include <stdio_ext.h>
  398. #include <locale.h>
  399. #include <stdlib.h>
  400. -#include <error.h>
  401. #include <string.h>
  402. #include <fnmatch.h>
  403. --- a/tests/md5-sha1-test.c
  404. +++ b/tests/md5-sha1-test.c
  405. @@ -19,7 +19,6 @@
  406. #endif
  407. #include <string.h>
  408. -#include <error.h>
  409. #include "md5.h"
  410. #include "sha1.h"
  411. --- a/tests/rdwrmmap.c
  412. +++ b/tests/rdwrmmap.c
  413. @@ -19,7 +19,6 @@
  414. #endif
  415. #include <errno.h>
  416. -#include <error.h>
  417. #include <stdio.h>
  418. #include <fcntl.h>
  419. #include <unistd.h>
  420. --- a/tests/saridx.c
  421. +++ b/tests/saridx.c
  422. @@ -17,7 +17,6 @@
  423. #include <config.h>
  424. -#include <error.h>
  425. #include <fcntl.h>
  426. #include <gelf.h>
  427. #include <stdio.h>
  428. --- a/tests/sectiondump.c
  429. +++ b/tests/sectiondump.c
  430. @@ -18,7 +18,6 @@
  431. #include <config.h>
  432. #include <errno.h>
  433. -#include <error.h>
  434. #include <fcntl.h>
  435. #include <gelf.h>
  436. #include <inttypes.h>
  437. --- a/tests/varlocs.c
  438. +++ b/tests/varlocs.c
  439. @@ -25,7 +25,6 @@
  440. #include <dwarf.h>
  441. #include <stdio.h>
  442. #include <stdlib.h>
  443. -#include <error.h>
  444. #include <string.h>
  445. #include <sys/types.h>
  446. #include <sys/stat.h>
  447. --- a/libasm/asm_end.c
  448. +++ b/libasm/asm_end.c
  449. @@ -32,7 +32,6 @@
  450. #endif
  451. #include <assert.h>
  452. -#include <error.h>
  453. #include <libintl.h>
  454. #include <stdio.h>
  455. #include <stdlib.h>
  456. --- a/libasm/asm_newscn.c
  457. +++ b/libasm/asm_newscn.c
  458. @@ -32,7 +32,6 @@
  459. #endif
  460. #include <assert.h>
  461. -#include <error.h>
  462. #include <libintl.h>
  463. #include <stdlib.h>
  464. #include <string.h>
  465. --- a/libcpu/i386_gendis.c
  466. +++ b/libcpu/i386_gendis.c
  467. @@ -31,7 +31,6 @@
  468. # include <config.h>
  469. #endif
  470. -#include <error.h>
  471. #include <errno.h>
  472. #include <stdio.h>
  473. #include <stdlib.h>
  474. --- a/libcpu/i386_lex.c
  475. +++ b/libcpu/i386_lex.c
  476. @@ -592,7 +592,6 @@ char *i386_text;
  477. #endif
  478. #include <ctype.h>
  479. -#include <error.h>
  480. #include <libintl.h>
  481. #include <libeu.h>
  482. --- a/libcpu/i386_lex.l
  483. +++ b/libcpu/i386_lex.l
  484. @@ -31,7 +31,6 @@
  485. #endif
  486. #include <ctype.h>
  487. -#include <error.h>
  488. #include <libintl.h>
  489. #include <libeu.h>
  490. --- a/libcpu/i386_parse.c
  491. +++ b/libcpu/i386_parse.c
  492. @@ -107,7 +107,6 @@
  493. #include <assert.h>
  494. #include <ctype.h>
  495. #include <errno.h>
  496. -#include <error.h>
  497. #include <inttypes.h>
  498. #include <libintl.h>
  499. #include <math.h>
  500. --- a/libdw/libdw_alloc.c
  501. +++ b/libdw/libdw_alloc.c
  502. @@ -31,7 +31,6 @@
  503. # include <config.h>
  504. #endif
  505. -#include <error.h>
  506. #include <errno.h>
  507. #include <stdlib.h>
  508. #include "libdwP.h"
  509. @@ -74,5 +73,5 @@ __attribute ((noreturn, visibility ("hid
  510. __libdw_oom (void)
  511. {
  512. while (1)
  513. - error (EXIT_FAILURE, ENOMEM, "libdw");
  514. + error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
  515. }
  516. --- a/libebl/eblopenbackend.c
  517. +++ b/libebl/eblopenbackend.c
  518. @@ -32,7 +32,6 @@
  519. #include <assert.h>
  520. #include <dlfcn.h>
  521. -#include <error.h>
  522. #include <libelfP.h>
  523. #include <dwarf.h>
  524. #include <stdlib.h>
  525. --- a/libdwfl/dwfl_error.c
  526. +++ b/libdwfl/dwfl_error.c
  527. @@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
  528. const char *
  529. dwfl_errmsg (int error)
  530. {
  531. + static __thread char s[64] = "";
  532. if (error == 0 || error == -1)
  533. {
  534. int last_error = global_error;
  535. @@ -154,7 +155,8 @@ dwfl_errmsg (int error)
  536. switch (error &~ 0xffff)
  537. {
  538. case OTHER_ERROR (ERRNO):
  539. - return strerror_r (error & 0xffff, "bad", 0);
  540. + strerror_r (error & 0xffff, s, sizeof(s));
  541. + return s;
  542. case OTHER_ERROR (LIBELF):
  543. return elf_errmsg (error & 0xffff);
  544. case OTHER_ERROR (LIBDW):