100-musl-compat.patch 12 KB

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