compress.exp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. # Copyright (C) 2010-2017 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
  15. # Test compressed .debug section.
  16. if { [is_remote host] || ![is_elf_format] } then {
  17. return
  18. }
  19. set testfile tmpdir/dw2-1
  20. set compressedfile tmpdir/dw2-1-compressed
  21. set copyfile tmpdir/dw2-copy
  22. set compressedfile2 tmpdir/dw2-2-compressed
  23. set libfile tmpdir/libdw2
  24. set compressedcopyfile tmpdir/dw2-copy-compressed
  25. set testfile3 tmpdir/dw2-3
  26. set compressedfile3 tmpdir/dw2-3-compressed
  27. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${testfile}.o --nocompress-debug-sections] } then {
  28. unsupported "compressed debug sections"
  29. return
  30. }
  31. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}.o --compress-debug-sections] } then {
  32. unsupported "compressed debug sections"
  33. return
  34. }
  35. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
  36. unsupported "compressed debug sections with zlib-gnu"
  37. return
  38. }
  39. set got [remote_exec host "cmp ${testfile}.o ${compressedfile}gnu.o"]
  40. # Use it to set up xfail.
  41. set exec_output [lindex $got 1]
  42. if [string match "" $exec_output] then {
  43. set compression_used ""
  44. } else {
  45. set compression_used "yes"
  46. }
  47. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}.o --compress-debug-sections] } then {
  48. unsupported "compressed debug sections"
  49. return
  50. }
  51. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o --nocompress-debug-sections] } then {
  52. unsupported "compressed debug sections"
  53. return
  54. }
  55. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}.o --compress-debug-sections] } then {
  56. unsupported "compressed debug sections"
  57. return
  58. }
  59. remote_file host delete ${libfile}.a
  60. set got [binutils_run $AR "rc ${libfile}.a ${compressedfile}.o ${compressedfile2}.o ${compressedfile3}.o"]
  61. if ![string match "" $got] then {
  62. fail "compressed debug sections"
  63. return
  64. }
  65. set testname "objcopy compress debug sections"
  66. set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}.o ${copyfile}.o"]
  67. if ![string match "" $got] then {
  68. fail "objcopy ($testname)"
  69. } else {
  70. send_log "cmp ${compressedfile}.o ${copyfile}.o\n"
  71. verbose "cmp ${compressedfile}.o ${copyfile}.o"
  72. set src1 ${compressedfile}.o
  73. set src2 ${copyfile}.o
  74. set status [remote_exec build cmp "${src1} ${src2}"]
  75. set exec_output [lindex $status 1]
  76. set exec_output [prune_warnings $exec_output]
  77. if [string match "" $exec_output] then {
  78. pass "objcopy ($testname)"
  79. } else {
  80. send_log "$exec_output\n"
  81. verbose "$exec_output" 1
  82. fail "objcopy ($testname)"
  83. }
  84. }
  85. set testname "objcopy decompress compressed debug sections"
  86. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}.o ${copyfile}.o"]
  87. if ![string match "" $got] then {
  88. fail "objcopy ($testname)"
  89. } else {
  90. send_log "cmp ${testfile}.o ${copyfile}.o\n"
  91. verbose "cmp ${testfile}.o ${copyfile}.o"
  92. set src1 ${testfile}.o
  93. set src2 ${copyfile}.o
  94. set status [remote_exec build cmp "${src1} ${src2}"]
  95. set exec_output [lindex $status 1]
  96. set exec_output [prune_warnings $exec_output]
  97. if [string match "" $exec_output] then {
  98. pass "objcopy ($testname)"
  99. } else {
  100. send_log "$exec_output\n"
  101. verbose "$exec_output" 1
  102. fail "objcopy ($testname)"
  103. }
  104. }
  105. set testname "objcopy decompress debug sections in archive"
  106. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}.a ${copyfile}.a"]
  107. if ![string match "" $got] then {
  108. fail "objcopy ($testname)"
  109. } else {
  110. set got [remote_exec host "$READELF -S --wide ${copyfile}.a" "" "/dev/null" "tmpdir/libdw2.out"]
  111. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  112. fail "$testname (reason: unexpected output)"
  113. send_log $got
  114. send_log "\n"
  115. }
  116. if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
  117. fail "$testname"
  118. } else {
  119. pass "$testname"
  120. }
  121. }
  122. # Xfail this test if there are no compressed sections.
  123. setup_xfail "$compression_used$target_triplet"
  124. set testname "objcopy compress debug sections in archive with zlib-gnu"
  125. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${copyfile}.a ${compressedcopyfile}.a"]
  126. if ![string match "" $got] then {
  127. fail "objcopy ($testname)"
  128. } else {
  129. set got [remote_exec host "$OBJDUMP -s -j .zdebug_line ${compressedcopyfile}.a" "" "/dev/null" "tmpdir/libdw2-compressed.out"]
  130. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  131. fail "$testname (reason: unexpected output)"
  132. send_log $got
  133. send_log "\n"
  134. }
  135. setup_xfail "$compression_used$target_triplet"
  136. if { [regexp_diff tmpdir/libdw2-compressed.out $srcdir/$subdir/libdw2-compressed.out] } then {
  137. fail "$testname"
  138. } else {
  139. pass "$testname"
  140. }
  141. }
  142. setup_xfail "nds32*-*-*"
  143. set testname "objdump compress debug sections"
  144. set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
  145. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  146. fail "$testname"
  147. send_log "$got\n"
  148. }
  149. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
  150. fail "$testname"
  151. } else {
  152. pass "$testname"
  153. }
  154. setup_xfail "nds32*-*-*"
  155. set testname "objdump compress debug sections 3"
  156. set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
  157. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  158. fail "$testname"
  159. send_log "$got\n"
  160. }
  161. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
  162. fail "$testname"
  163. } else {
  164. pass "$testname"
  165. }
  166. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S ${testfile}empty.o --nocompress-debug-sections] } then {
  167. unsupported "compressed debug sections"
  168. return
  169. }
  170. set testname "objcopy compress empty debug sections"
  171. set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}empty.o ${copyfile}empty.o"]
  172. if ![string match "" $got] then {
  173. fail "objcopy ($testname)"
  174. } else {
  175. send_log "cmp ${testfile}empty.o ${copyfile}empty.o\n"
  176. verbose "cmp ${testfile}empty.o ${copyfile}empty.o"
  177. set src1 ${testfile}empty.o
  178. set src2 ${copyfile}empty.o
  179. set status [remote_exec build cmp "${src1} ${src2}"]
  180. set exec_output [lindex $status 1]
  181. set exec_output [prune_warnings $exec_output]
  182. if [string match "" $exec_output] then {
  183. pass "objcopy ($testname)"
  184. } else {
  185. send_log "$exec_output\n"
  186. verbose "$exec_output" 1
  187. fail "objcopy ($testname)"
  188. }
  189. }
  190. if ![is_remote host] {
  191. set tempfile tmpdir/debug_str.o
  192. set copyfile tmpdir/debug_str.copy
  193. } else {
  194. set tempfile [remote_download host tmpdir/debug_str.o]
  195. set copyfile debug_str.copy
  196. }
  197. run_dump_test "debug_str"
  198. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gabi.o --compress-debug-sections=zlib-gabi] } then {
  199. fail "compressed debug sections with zlib-gabi"
  200. return
  201. }
  202. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
  203. fail "compressed debug sections with zlib-gnu"
  204. return
  205. }
  206. set src1 ${compressedfile}gabi.o
  207. set src2 ${compressedfile}.o
  208. set status [remote_exec build cmp "${src1} ${src2}"]
  209. set exec_output [lindex $status 1]
  210. set exec_output [prune_warnings $exec_output]
  211. if ![string match "" $exec_output] then {
  212. fail "compressed debug sections with zlib-gabi"
  213. return
  214. }
  215. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gabi.o --compress-debug-sections=zlib-gabi] } then {
  216. fail "compressed debug sections with zlib-gabi"
  217. return
  218. }
  219. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gnu.o --compress-debug-sections=zlib-gnu] } then {
  220. fail "compressed debug sections with zlib-gnu"
  221. return
  222. }
  223. set src1 ${compressedfile2}gabi.o
  224. set src2 ${compressedfile2}.o
  225. set status [remote_exec build cmp "${src1} ${src2}"]
  226. set exec_output [lindex $status 1]
  227. set exec_output [prune_warnings $exec_output]
  228. if ![string match "" $exec_output] then {
  229. fail "compressed debug sections with zlib-gabi"
  230. return
  231. }
  232. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gabi.o --compress-debug-sections=zlib-gabi] } then {
  233. fail "compressed debug sections with zlib-gabi"
  234. return
  235. }
  236. set testname "readelf -t zlib-gabi compress debug sections"
  237. set got [remote_exec host "$READELF -t --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rt"]
  238. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  239. fail "$testname (reason: unexpected output)"
  240. send_log "$got\n"
  241. }
  242. if { [regexp_diff tmpdir/dw2-3.rt $srcdir/$subdir/dw2-3.rt] } then {
  243. fail "$testname"
  244. } else {
  245. pass "$testname"
  246. }
  247. set testname "readelf -S zlib-gabi compress debug sections"
  248. set got [remote_exec host "$READELF -S --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rS"]
  249. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  250. fail "$testname (reason: unexpected output)"
  251. send_log "$got\n"
  252. }
  253. if { [regexp_diff tmpdir/dw2-3.rS $srcdir/$subdir/dw2-3.rS] } then {
  254. fail "$testname"
  255. } else {
  256. pass "$testname"
  257. }
  258. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gnu.o --compress-debug-sections=zlib-gnu] } then {
  259. fail "compressed debug sections with zlib-gnu"
  260. return
  261. }
  262. set src1 ${compressedfile3}gabi.o
  263. set src2 ${compressedfile3}.o
  264. set status [remote_exec build cmp "${src1} ${src2}"]
  265. set exec_output [lindex $status 1]
  266. set exec_output [prune_warnings $exec_output]
  267. if ![string match "" $exec_output] then {
  268. fail "compressed debug sections with zlib-gabi"
  269. return
  270. }
  271. remote_file host delete ${libfile}gabi.a
  272. set got [binutils_run $AR "rc ${libfile}gabi.a ${compressedfile}gabi.o ${compressedfile2}gabi.o ${compressedfile3}gabi.o"]
  273. if ![string match "" $got] then {
  274. fail "compressed debug sections"
  275. return
  276. }
  277. set testname "objcopy compress debug sections with zlib-gabi"
  278. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile}.o ${copyfile}gabi.o"]
  279. if ![string match "" $got] then {
  280. fail "objcopy ($testname)"
  281. return
  282. }
  283. send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
  284. verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
  285. set src1 ${compressedfile}gabi.o
  286. set src2 ${copyfile}gabi.o
  287. set status [remote_exec build cmp "${src1} ${src2}"]
  288. set exec_output [lindex $status 1]
  289. set exec_output [prune_warnings $exec_output]
  290. if ![string match "" $exec_output] then {
  291. send_log "$exec_output\n"
  292. verbose "$exec_output" 1
  293. fail "objcopy ($testname)"
  294. } else {
  295. pass "objcopy ($testname)"
  296. }
  297. set testname "objcopy decompress compressed debug sections with zlib-gabi"
  298. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}gabi.o ${copyfile}gabi.o"]
  299. if ![string match "" $got] then {
  300. fail "objcopy ($testname)"
  301. return
  302. }
  303. send_log "cmp ${testfile}.o ${copyfile}gabi.o\n"
  304. verbose "cmp ${testfile}.o ${copyfile}gabi.o"
  305. set src1 ${testfile}.o
  306. set src2 ${copyfile}gabi.o
  307. set status [remote_exec build cmp "${src1} ${src2}"]
  308. set exec_output [lindex $status 1]
  309. set exec_output [prune_warnings $exec_output]
  310. if ![string match "" $exec_output] then {
  311. send_log "$exec_output\n"
  312. verbose "$exec_output" 1
  313. fail "objcopy ($testname)"
  314. } else {
  315. pass "objcopy ($testname)"
  316. }
  317. set testname "objcopy zlib-gnu compress debug sections with zlib-gabi"
  318. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile}.o ${copyfile}gabi.o"]
  319. if ![string match "" $got] then {
  320. fail "objcopy ($testname)"
  321. return
  322. }
  323. send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
  324. verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
  325. set src1 ${compressedfile}gabi.o
  326. set src2 ${copyfile}gabi.o
  327. set status [remote_exec build cmp "${src1} ${src2}"]
  328. set exec_output [lindex $status 1]
  329. set exec_output [prune_warnings $exec_output]
  330. if ![string match "" $exec_output] then {
  331. send_log "$exec_output\n"
  332. verbose "$exec_output" 1
  333. fail "objcopy ($testname)"
  334. } else {
  335. pass "objcopy ($testname)"
  336. }
  337. set testname "objcopy zlib-gabi compress debug sections with zlib-gnu"
  338. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile}gabi.o ${copyfile}gnu.o"]
  339. if ![string match "" $got] then {
  340. fail "objcopy ($testname)"
  341. return
  342. }
  343. send_log "cmp ${compressedfile}gnu.o ${copyfile}gnu.o\n"
  344. verbose "cmp ${compressedfile}gnu.o ${copyfile}gnu.o"
  345. set src1 ${compressedfile}gnu.o
  346. set src2 ${copyfile}gnu.o
  347. set status [remote_exec build cmp "${src1} ${src2}"]
  348. set exec_output [lindex $status 1]
  349. set exec_output [prune_warnings $exec_output]
  350. if ![string match "" $exec_output] then {
  351. send_log "$exec_output\n"
  352. verbose "$exec_output" 1
  353. fail "objcopy ($testname)"
  354. } else {
  355. pass "objcopy ($testname)"
  356. }
  357. set testname "objcopy compress debug sections 3 with zlib-gabi"
  358. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile3}.o ${copyfile}gabi.o"]
  359. if ![string match "" $got] then {
  360. fail "objcopy ($testname)"
  361. return
  362. }
  363. send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
  364. verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
  365. set src1 ${compressedfile3}gabi.o
  366. set src2 ${copyfile}gabi.o
  367. set status [remote_exec build cmp "${src1} ${src2}"]
  368. set exec_output [lindex $status 1]
  369. set exec_output [prune_warnings $exec_output]
  370. if ![string match "" $exec_output] then {
  371. send_log "$exec_output\n"
  372. verbose "$exec_output" 1
  373. fail "objcopy ($testname)"
  374. } else {
  375. pass "objcopy ($testname)"
  376. }
  377. set testname "objcopy decompress compressed debug sections 3 with zlib-gabi"
  378. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile3}gabi.o ${copyfile}gabi.o"]
  379. if ![string match "" $got] then {
  380. fail "objcopy ($testname)"
  381. return
  382. }
  383. send_log "cmp ${testfile3}.o ${copyfile}gabi.o\n"
  384. verbose "cmp ${testfile3}.o ${copyfile}gabi.o"
  385. set src1 ${testfile3}.o
  386. set src2 ${copyfile}gabi.o
  387. set status [remote_exec build cmp "${src1} ${src2}"]
  388. set exec_output [lindex $status 1]
  389. set exec_output [prune_warnings $exec_output]
  390. if ![string match "" $exec_output] then {
  391. send_log "$exec_output\n"
  392. verbose "$exec_output" 1
  393. fail "objcopy ($testname)"
  394. } else {
  395. pass "objcopy ($testname)"
  396. }
  397. set testname "objcopy zlib-gnu compress debug sections 3 with zlib-gabi"
  398. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile3}.o ${copyfile}gabi.o"]
  399. if ![string match "" $got] then {
  400. fail "objcopy ($testname)"
  401. return
  402. }
  403. send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
  404. verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
  405. set src1 ${compressedfile3}gabi.o
  406. set src2 ${copyfile}gabi.o
  407. set status [remote_exec build cmp "${src1} ${src2}"]
  408. set exec_output [lindex $status 1]
  409. set exec_output [prune_warnings $exec_output]
  410. if ![string match "" $exec_output] then {
  411. send_log "$exec_output\n"
  412. verbose "$exec_output" 1
  413. fail "objcopy ($testname)"
  414. } else {
  415. pass "objcopy ($testname)"
  416. }
  417. set testname "objcopy zlib-gabi compress debug sections 3 with zlib-gnu"
  418. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile3}gabi.o ${copyfile}gnu.o"]
  419. if ![string match "" $got] then {
  420. fail "objcopy ($testname)"
  421. return
  422. }
  423. send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
  424. verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
  425. set src1 ${compressedfile3}gnu.o
  426. set src2 ${copyfile}gnu.o
  427. set status [remote_exec build cmp "${src1} ${src2}"]
  428. set exec_output [lindex $status 1]
  429. set exec_output [prune_warnings $exec_output]
  430. if ![string match "" $exec_output] then {
  431. send_log "$exec_output\n"
  432. verbose "$exec_output" 1
  433. fail "objcopy ($testname)"
  434. } else {
  435. pass "objcopy ($testname)"
  436. }
  437. set testname "objcopy zlib-gnu compress debug sections 3"
  438. set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
  439. if ![string match "" $got] then {
  440. fail "objcopy ($testname)"
  441. return
  442. }
  443. send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
  444. verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
  445. set src1 ${compressedfile3}gnu.o
  446. set src2 ${copyfile}gnu.o
  447. set status [remote_exec build cmp "${src1} ${src2}"]
  448. set exec_output [lindex $status 1]
  449. set exec_output [prune_warnings $exec_output]
  450. if ![string match "" $exec_output] then {
  451. send_log "$exec_output\n"
  452. verbose "$exec_output" 1
  453. fail "objcopy ($testname)"
  454. } else {
  455. pass "objcopy ($testname)"
  456. }
  457. set testname "objcopy zlib-gnu compress debug sections 3"
  458. set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
  459. if ![string match "" $got] then {
  460. fail "objcopy ($testname)"
  461. return
  462. }
  463. send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
  464. verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
  465. set src1 ${compressedfile3}gnu.o
  466. set src2 ${copyfile}gnu.o
  467. set status [remote_exec build cmp "${src1} ${src2}"]
  468. set exec_output [lindex $status 1]
  469. set exec_output [prune_warnings $exec_output]
  470. if ![string match "" $exec_output] then {
  471. send_log "$exec_output\n"
  472. verbose "$exec_output" 1
  473. fail "objcopy ($testname)"
  474. } else {
  475. pass "objcopy ($testname)"
  476. }
  477. set testname "objcopy decompress debug sections in archive with zlib-gabi"
  478. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}gabi.a ${copyfile}gabi.a"]
  479. if ![string match "" $got] then {
  480. fail "objcopy ($testname)"
  481. } else {
  482. set got [remote_exec host "$READELF -S --wide ${copyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2.out"]
  483. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  484. fail "$testname (reason: unexpected output)"
  485. send_log $got
  486. send_log "\n"
  487. }
  488. if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
  489. fail "$testname"
  490. } else {
  491. pass "$testname"
  492. }
  493. }
  494. setup_xfail "nds32*-*-*"
  495. set testname "objcopy compress debug sections in archive with zlib-gabi"
  496. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
  497. if ![string match "" $got] then {
  498. fail "objcopy ($testname)"
  499. } else {
  500. set got [remote_exec host "$OBJDUMP -W ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
  501. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  502. fail "$testname (reason: unexpected output)"
  503. send_log $got
  504. send_log "\n"
  505. }
  506. if { [regexp_diff tmpdir/libdw2-compressedgabi.out $srcdir/$subdir/libdw2-compressedgabi.out] } then {
  507. fail "$testname"
  508. } else {
  509. pass "$testname"
  510. }
  511. }
  512. setup_xfail "nds32*-*-*"
  513. set testname "objdump compress debug sections 3 with zlib-gabi"
  514. set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
  515. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  516. fail "$testname"
  517. send_log "$got\n"
  518. }
  519. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {
  520. fail "$testname"
  521. } else {
  522. pass "$testname"
  523. }
  524. proc convert_test { testname as_flags objcop_flags } {
  525. global srcdir
  526. global subdir
  527. global testfile3
  528. global copyfile
  529. global OBJCOPY
  530. global OBJDUMP
  531. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o "$as_flags"] } then {
  532. unresolved "$testname"
  533. return
  534. }
  535. set got [binutils_run $OBJCOPY "$objcop_flags ${testfile3}.o ${copyfile}.o"]
  536. if ![string match "" $got] then {
  537. fail "objcopy ($testname)"
  538. return
  539. }
  540. set got [remote_exec host "$OBJDUMP -W ${copyfile}.o" "" "/dev/null" "objdump.out"]
  541. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  542. fail "$testname (reason: unexpected output)"
  543. send_log $got
  544. send_log "\n"
  545. return
  546. }
  547. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
  548. fail "$testname"
  549. } else {
  550. pass "$testname"
  551. }
  552. }
  553. if { ([istarget "x86_64-*-elf*"]
  554. || [istarget "x86_64-*-linux*"]) } {
  555. set testname "Convert x86-64 object with zlib-gabi to x32 (1)"
  556. convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64"
  557. set testname "Convert x86-64 object with zlib-gabi to x32 (2)"
  558. convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
  559. set testname "Convert x86-64 object with zlib-gabi to x32 (3)"
  560. convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --decompress-debug-sections"
  561. set testname "Convert x86-64 object with zlib-gnu to x32 (1)"
  562. convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64"
  563. set testname "Convert x86-64 object with zlib-gnu to x32 (2)"
  564. convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
  565. set testname "Convert x86-64 object with zlib-gnu to x32 (3)"
  566. convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --decompress-debug-sections"
  567. set testname "Convert x86-64 object to x32 (1)"
  568. convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64"
  569. set testname "Convert x86-64 object to x32 (2)"
  570. convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
  571. set testname "Convert x86-64 object to x32 (3)"
  572. convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
  573. set testname "Convert x32 object with zlib-gabi to x86-64 (1)"
  574. convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64"
  575. set testname "Convert x32 object with zlib-gabi to x86-64 (2)"
  576. convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
  577. set testname "Convert x32 object with zlib-gabi to x86-64 (3)"
  578. convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --decompress-debug-sections"
  579. set testname "Convert x32 object with zlib-gnu to x86-64 (1)"
  580. convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64"
  581. set testname "Convert x32 object with zlib-gnu to x86-64 (2)"
  582. convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
  583. set testname "Convert x32 object with zlib-gnu to x86-64 (3)"
  584. convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --decompress-debug-sections"
  585. set testname "Convert x32 object to x86-64 (1)"
  586. convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64"
  587. set testname "Convert x32 object to x86-64 (2)"
  588. convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
  589. set testname "Convert x32 object to x86-64 (3)"
  590. convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
  591. }
  592. proc test_gnu_debuglink {} {
  593. global srcdir
  594. global subdir
  595. global env
  596. global CC_FOR_TARGET
  597. global STRIP
  598. global OBJCOPY
  599. global OBJDUMP
  600. set test "gnu-debuglink"
  601. if {![info exists CC_FOR_TARGET]} {
  602. set CC_FOR_TARGET $env(CC)
  603. }
  604. if { $CC_FOR_TARGET == "" } {
  605. unsupported $test
  606. return
  607. }
  608. if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog exectuable debug] != "" } {
  609. fail "$test (build)"
  610. return
  611. }
  612. set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.dump"]
  613. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  614. fail "$test (objcopy dump)"
  615. return
  616. }
  617. if { [binutils_run $STRIP "--strip-debug --remove-section=.comment --remove-section=.note tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
  618. fail "$test (strip)"
  619. return
  620. }
  621. if { [binutils_run $OBJCOPY "--only-keep-debug --decompress-debug-sections tmpdir/testprog tmpdir/testprog.decompress"] != "" } {
  622. fail "$test (objcopy decompress)"
  623. return
  624. }
  625. if { [binutils_run $OBJCOPY "--only-keep-debug --compress-debug-sections tmpdir/testprog tmpdir/testprog.compress"] != "" } {
  626. fail "$test (objcopy compress)"
  627. return
  628. }
  629. if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.decompress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
  630. fail "$test (objcopy link decompress)"
  631. return
  632. }
  633. set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.decompress.dump"]
  634. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  635. fail "$test (objcopy dump decompress)"
  636. return
  637. }
  638. if { [binutils_run $OBJCOPY "--add-gnu-debuglink=tmpdir/testprog.compress tmpdir/testprog.strip tmpdir/testprog"] != "" } {
  639. fail "$test (objcopy link compress)"
  640. return
  641. }
  642. set got [remote_exec host "$OBJDUMP -S tmpdir/testprog" "" "/dev/null" "tmpdir/testprog.compress.dump"]
  643. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  644. fail "$test (objcopy dump compress)"
  645. return
  646. }
  647. set src1 tmpdir/testprog.dump
  648. set src2 tmpdir/testprog.compress.dump
  649. send_log "cmp ${src1} ${src2}\n"
  650. verbose "cmp ${src1} ${src2}"
  651. set status [remote_exec build cmp "${src1} ${src2}"]
  652. set exec_output [lindex $status 1]
  653. set exec_output [prune_warnings $exec_output]
  654. if ![string match "" $exec_output] then {
  655. send_log "$exec_output\n"
  656. verbose "$exec_output" 1
  657. fail "$test (objdump 1)"
  658. } else {
  659. pass "$test (objdump 1)"
  660. }
  661. set src1 tmpdir/testprog.decompress.dump
  662. set src2 tmpdir/testprog.compress.dump
  663. send_log "cmp ${src1} ${src2}\n"
  664. verbose "cmp ${src1} ${src2}"
  665. set status [remote_exec build cmp "${src1} ${src2}"]
  666. set exec_output [lindex $status 1]
  667. set exec_output [prune_warnings $exec_output]
  668. if ![string match "" $exec_output] then {
  669. send_log "$exec_output\n"
  670. verbose "$exec_output" 1
  671. fail "$test (objdump 2)"
  672. } else {
  673. pass "$test (objdump 2)"
  674. }
  675. }
  676. if {[isnative] && [is_elf_format]} then {
  677. test_gnu_debuglink
  678. }