compress.exp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. # Copyright (C) 2010-2015 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. set testname "objdump compress debug sections"
  143. set got [remote_exec host "$OBJDUMP -W ${compressedfile}.o" "" "/dev/null" "objdump.out"]
  144. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  145. fail "$testname"
  146. send_log "$got\n"
  147. }
  148. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-1.W] } then {
  149. fail "$testname"
  150. } else {
  151. pass "$testname"
  152. }
  153. set testname "objdump compress debug sections 3"
  154. set got [remote_exec host "$OBJDUMP -W ${compressedfile3}.o" "" "/dev/null" "objdump.out"]
  155. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  156. fail "$testname"
  157. send_log "$got\n"
  158. }
  159. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
  160. fail "$testname"
  161. } else {
  162. pass "$testname"
  163. }
  164. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-empty.S ${testfile}empty.o --nocompress-debug-sections] } then {
  165. unsupported "compressed debug sections"
  166. return
  167. }
  168. set testname "objcopy compress empty debug sections"
  169. set got [binutils_run $OBJCOPY "--compress-debug-sections ${testfile}empty.o ${copyfile}empty.o"]
  170. if ![string match "" $got] then {
  171. fail "objcopy ($testname)"
  172. } else {
  173. send_log "cmp ${testfile}empty.o ${copyfile}empty.o\n"
  174. verbose "cmp ${testfile}empty.o ${copyfile}empty.o"
  175. set src1 ${testfile}empty.o
  176. set src2 ${copyfile}empty.o
  177. set status [remote_exec build cmp "${src1} ${src2}"]
  178. set exec_output [lindex $status 1]
  179. set exec_output [prune_warnings $exec_output]
  180. if [string match "" $exec_output] then {
  181. pass "objcopy ($testname)"
  182. } else {
  183. send_log "$exec_output\n"
  184. verbose "$exec_output" 1
  185. fail "objcopy ($testname)"
  186. }
  187. }
  188. if ![is_remote host] {
  189. set tempfile tmpdir/debug_str.o
  190. set copyfile tmpdir/debug_str.copy
  191. } else {
  192. set tempfile [remote_download host tmpdir/debug_str.o]
  193. set copyfile debug_str.copy
  194. }
  195. run_dump_test "debug_str"
  196. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gabi.o --compress-debug-sections=zlib-gabi] } then {
  197. fail "compressed debug sections with zlib-gabi"
  198. return
  199. }
  200. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-1.S ${compressedfile}gnu.o --compress-debug-sections=zlib-gnu] } then {
  201. fail "compressed debug sections with zlib-gnu"
  202. return
  203. }
  204. set src1 ${compressedfile}gabi.o
  205. set src2 ${compressedfile}.o
  206. set status [remote_exec build cmp "${src1} ${src2}"]
  207. set exec_output [lindex $status 1]
  208. set exec_output [prune_warnings $exec_output]
  209. if ![string match "" $exec_output] then {
  210. fail "compressed debug sections with zlib-gabi"
  211. return
  212. }
  213. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gabi.o --compress-debug-sections=zlib-gabi] } then {
  214. fail "compressed debug sections with zlib-gabi"
  215. return
  216. }
  217. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-2.S ${compressedfile2}gnu.o --compress-debug-sections=zlib-gnu] } then {
  218. fail "compressed debug sections with zlib-gnu"
  219. return
  220. }
  221. set src1 ${compressedfile2}gabi.o
  222. set src2 ${compressedfile2}.o
  223. set status [remote_exec build cmp "${src1} ${src2}"]
  224. set exec_output [lindex $status 1]
  225. set exec_output [prune_warnings $exec_output]
  226. if ![string match "" $exec_output] then {
  227. fail "compressed debug sections with zlib-gabi"
  228. return
  229. }
  230. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gabi.o --compress-debug-sections=zlib-gabi] } then {
  231. fail "compressed debug sections with zlib-gabi"
  232. return
  233. }
  234. set testname "readelf -t zlib-gabi compress debug sections"
  235. set got [remote_exec host "$READELF -t --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rt"]
  236. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  237. fail "$testname (reason: unexpected output)"
  238. send_log "$got\n"
  239. }
  240. if { [regexp_diff tmpdir/dw2-3.rt $srcdir/$subdir/dw2-3.rt] } then {
  241. fail "$testname"
  242. } else {
  243. pass "$testname"
  244. }
  245. set testname "readelf -S zlib-gabi compress debug sections"
  246. set got [remote_exec host "$READELF -S --wide ${compressedfile3}gabi.o" "" "/dev/null" "tmpdir/dw2-3.rS"]
  247. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  248. fail "$testname (reason: unexpected output)"
  249. send_log "$got\n"
  250. }
  251. if { [regexp_diff tmpdir/dw2-3.rS $srcdir/$subdir/dw2-3.rS] } then {
  252. fail "$testname"
  253. } else {
  254. pass "$testname"
  255. }
  256. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${compressedfile3}gnu.o --compress-debug-sections=zlib-gnu] } then {
  257. fail "compressed debug sections with zlib-gnu"
  258. return
  259. }
  260. set src1 ${compressedfile3}gabi.o
  261. set src2 ${compressedfile3}.o
  262. set status [remote_exec build cmp "${src1} ${src2}"]
  263. set exec_output [lindex $status 1]
  264. set exec_output [prune_warnings $exec_output]
  265. if ![string match "" $exec_output] then {
  266. fail "compressed debug sections with zlib-gabi"
  267. return
  268. }
  269. remote_file host delete ${libfile}gabi.a
  270. set got [binutils_run $AR "rc ${libfile}gabi.a ${compressedfile}gabi.o ${compressedfile2}gabi.o ${compressedfile3}gabi.o"]
  271. if ![string match "" $got] then {
  272. fail "compressed debug sections"
  273. return
  274. }
  275. set testname "objcopy compress debug sections with zlib-gabi"
  276. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile}.o ${copyfile}gabi.o"]
  277. if ![string match "" $got] then {
  278. fail "objcopy ($testname)"
  279. return
  280. }
  281. send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
  282. verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
  283. set src1 ${compressedfile}gabi.o
  284. set src2 ${copyfile}gabi.o
  285. set status [remote_exec build cmp "${src1} ${src2}"]
  286. set exec_output [lindex $status 1]
  287. set exec_output [prune_warnings $exec_output]
  288. if ![string match "" $exec_output] then {
  289. send_log "$exec_output\n"
  290. verbose "$exec_output" 1
  291. fail "objcopy ($testname)"
  292. } else {
  293. pass "objcopy ($testname)"
  294. }
  295. set testname "objcopy decompress compressed debug sections with zlib-gabi"
  296. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile}gabi.o ${copyfile}gabi.o"]
  297. if ![string match "" $got] then {
  298. fail "objcopy ($testname)"
  299. return
  300. }
  301. send_log "cmp ${testfile}.o ${copyfile}gabi.o\n"
  302. verbose "cmp ${testfile}.o ${copyfile}gabi.o"
  303. set src1 ${testfile}.o
  304. set src2 ${copyfile}gabi.o
  305. set status [remote_exec build cmp "${src1} ${src2}"]
  306. set exec_output [lindex $status 1]
  307. set exec_output [prune_warnings $exec_output]
  308. if ![string match "" $exec_output] then {
  309. send_log "$exec_output\n"
  310. verbose "$exec_output" 1
  311. fail "objcopy ($testname)"
  312. } else {
  313. pass "objcopy ($testname)"
  314. }
  315. set testname "objcopy zlib-gnu compress debug sections with zlib-gabi"
  316. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile}.o ${copyfile}gabi.o"]
  317. if ![string match "" $got] then {
  318. fail "objcopy ($testname)"
  319. return
  320. }
  321. send_log "cmp ${compressedfile}gabi.o ${copyfile}gabi.o\n"
  322. verbose "cmp ${compressedfile}gabi.o ${copyfile}gabi.o"
  323. set src1 ${compressedfile}gabi.o
  324. set src2 ${copyfile}gabi.o
  325. set status [remote_exec build cmp "${src1} ${src2}"]
  326. set exec_output [lindex $status 1]
  327. set exec_output [prune_warnings $exec_output]
  328. if ![string match "" $exec_output] then {
  329. send_log "$exec_output\n"
  330. verbose "$exec_output" 1
  331. fail "objcopy ($testname)"
  332. } else {
  333. pass "objcopy ($testname)"
  334. }
  335. set testname "objcopy zlib-gabi compress debug sections with zlib-gnu"
  336. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile}gabi.o ${copyfile}gnu.o"]
  337. if ![string match "" $got] then {
  338. fail "objcopy ($testname)"
  339. return
  340. }
  341. send_log "cmp ${compressedfile}gnu.o ${copyfile}gnu.o\n"
  342. verbose "cmp ${compressedfile}gnu.o ${copyfile}gnu.o"
  343. set src1 ${compressedfile}gnu.o
  344. set src2 ${copyfile}gnu.o
  345. set status [remote_exec build cmp "${src1} ${src2}"]
  346. set exec_output [lindex $status 1]
  347. set exec_output [prune_warnings $exec_output]
  348. if ![string match "" $exec_output] then {
  349. send_log "$exec_output\n"
  350. verbose "$exec_output" 1
  351. fail "objcopy ($testname)"
  352. } else {
  353. pass "objcopy ($testname)"
  354. }
  355. set testname "objcopy compress debug sections 3 with zlib-gabi"
  356. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${testfile3}.o ${copyfile}gabi.o"]
  357. if ![string match "" $got] then {
  358. fail "objcopy ($testname)"
  359. return
  360. }
  361. send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
  362. verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
  363. set src1 ${compressedfile3}gabi.o
  364. set src2 ${copyfile}gabi.o
  365. set status [remote_exec build cmp "${src1} ${src2}"]
  366. set exec_output [lindex $status 1]
  367. set exec_output [prune_warnings $exec_output]
  368. if ![string match "" $exec_output] then {
  369. send_log "$exec_output\n"
  370. verbose "$exec_output" 1
  371. fail "objcopy ($testname)"
  372. } else {
  373. pass "objcopy ($testname)"
  374. }
  375. set testname "objcopy decompress compressed debug sections 3 with zlib-gabi"
  376. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${compressedfile3}gabi.o ${copyfile}gabi.o"]
  377. if ![string match "" $got] then {
  378. fail "objcopy ($testname)"
  379. return
  380. }
  381. send_log "cmp ${testfile3}.o ${copyfile}gabi.o\n"
  382. verbose "cmp ${testfile3}.o ${copyfile}gabi.o"
  383. set src1 ${testfile3}.o
  384. set src2 ${copyfile}gabi.o
  385. set status [remote_exec build cmp "${src1} ${src2}"]
  386. set exec_output [lindex $status 1]
  387. set exec_output [prune_warnings $exec_output]
  388. if ![string match "" $exec_output] then {
  389. send_log "$exec_output\n"
  390. verbose "$exec_output" 1
  391. fail "objcopy ($testname)"
  392. } else {
  393. pass "objcopy ($testname)"
  394. }
  395. set testname "objcopy zlib-gnu compress debug sections 3 with zlib-gabi"
  396. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${compressedfile3}.o ${copyfile}gabi.o"]
  397. if ![string match "" $got] then {
  398. fail "objcopy ($testname)"
  399. return
  400. }
  401. send_log "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o\n"
  402. verbose "cmp ${compressedfile3}gabi.o ${copyfile}gabi.o"
  403. set src1 ${compressedfile3}gabi.o
  404. set src2 ${copyfile}gabi.o
  405. set status [remote_exec build cmp "${src1} ${src2}"]
  406. set exec_output [lindex $status 1]
  407. set exec_output [prune_warnings $exec_output]
  408. if ![string match "" $exec_output] then {
  409. send_log "$exec_output\n"
  410. verbose "$exec_output" 1
  411. fail "objcopy ($testname)"
  412. } else {
  413. pass "objcopy ($testname)"
  414. }
  415. set testname "objcopy zlib-gabi compress debug sections 3 with zlib-gnu"
  416. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gnu ${compressedfile3}gabi.o ${copyfile}gnu.o"]
  417. if ![string match "" $got] then {
  418. fail "objcopy ($testname)"
  419. return
  420. }
  421. send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
  422. verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
  423. set src1 ${compressedfile3}gnu.o
  424. set src2 ${copyfile}gnu.o
  425. set status [remote_exec build cmp "${src1} ${src2}"]
  426. set exec_output [lindex $status 1]
  427. set exec_output [prune_warnings $exec_output]
  428. if ![string match "" $exec_output] then {
  429. send_log "$exec_output\n"
  430. verbose "$exec_output" 1
  431. fail "objcopy ($testname)"
  432. } else {
  433. pass "objcopy ($testname)"
  434. }
  435. set testname "objcopy zlib-gnu compress debug sections 3"
  436. set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
  437. if ![string match "" $got] then {
  438. fail "objcopy ($testname)"
  439. return
  440. }
  441. send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
  442. verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
  443. set src1 ${compressedfile3}gnu.o
  444. set src2 ${copyfile}gnu.o
  445. set status [remote_exec build cmp "${src1} ${src2}"]
  446. set exec_output [lindex $status 1]
  447. set exec_output [prune_warnings $exec_output]
  448. if ![string match "" $exec_output] then {
  449. send_log "$exec_output\n"
  450. verbose "$exec_output" 1
  451. fail "objcopy ($testname)"
  452. } else {
  453. pass "objcopy ($testname)"
  454. }
  455. set testname "objcopy zlib-gnu compress debug sections 3"
  456. set got [binutils_run $OBJCOPY "${compressedfile3}gnu.o ${copyfile}gnu.o"]
  457. if ![string match "" $got] then {
  458. fail "objcopy ($testname)"
  459. return
  460. }
  461. send_log "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o\n"
  462. verbose "cmp ${compressedfile3}gnu.o ${copyfile}gnu.o"
  463. set src1 ${compressedfile3}gnu.o
  464. set src2 ${copyfile}gnu.o
  465. set status [remote_exec build cmp "${src1} ${src2}"]
  466. set exec_output [lindex $status 1]
  467. set exec_output [prune_warnings $exec_output]
  468. if ![string match "" $exec_output] then {
  469. send_log "$exec_output\n"
  470. verbose "$exec_output" 1
  471. fail "objcopy ($testname)"
  472. } else {
  473. pass "objcopy ($testname)"
  474. }
  475. set testname "objcopy decompress debug sections in archive with zlib-gabi"
  476. set got [binutils_run $OBJCOPY "--decompress-debug-sections ${libfile}gabi.a ${copyfile}gabi.a"]
  477. if ![string match "" $got] then {
  478. fail "objcopy ($testname)"
  479. } else {
  480. set got [remote_exec host "$READELF -S --wide ${copyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2.out"]
  481. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  482. fail "$testname (reason: unexpected output)"
  483. send_log $got
  484. send_log "\n"
  485. }
  486. if { [regexp_diff tmpdir/libdw2.out $srcdir/$subdir/libdw2.out] } then {
  487. fail "$testname"
  488. } else {
  489. pass "$testname"
  490. }
  491. }
  492. set testname "objcopy compress debug sections in archive with zlib-gabi"
  493. set got [binutils_run $OBJCOPY "--compress-debug-sections=zlib-gabi ${copyfile}gabi.a ${compressedcopyfile}gabi.a"]
  494. if ![string match "" $got] then {
  495. fail "objcopy ($testname)"
  496. } else {
  497. set got [remote_exec host "$OBJDUMP -W ${compressedcopyfile}gabi.a" "" "/dev/null" "tmpdir/libdw2-compressedgabi.out"]
  498. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  499. fail "$testname (reason: unexpected output)"
  500. send_log $got
  501. send_log "\n"
  502. }
  503. if { [regexp_diff tmpdir/libdw2-compressedgabi.out $srcdir/$subdir/libdw2-compressedgabi.out] } then {
  504. fail "$testname"
  505. } else {
  506. pass "$testname"
  507. }
  508. }
  509. set testname "objdump compress debug sections 3 with zlib-gabi"
  510. set got [remote_exec host "$OBJDUMP -W ${compressedfile3}gabi.o" "" "/dev/null" "objdump.out"]
  511. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  512. fail "$testname"
  513. send_log "$got\n"
  514. }
  515. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3gabi.W] } then {
  516. fail "$testname"
  517. } else {
  518. pass "$testname"
  519. }
  520. proc convert_test { testname as_flags objcop_flags } {
  521. global srcdir
  522. global subdir
  523. global testfile3
  524. global copyfile
  525. global OBJCOPY
  526. global OBJDUMP
  527. if { ![binutils_assemble_flags $srcdir/$subdir/dw2-3.S ${testfile3}.o "$as_flags"] } then {
  528. unresolved "$testname"
  529. return
  530. }
  531. set got [binutils_run $OBJCOPY "$objcop_flags ${testfile3}.o ${copyfile}.o"]
  532. if ![string match "" $got] then {
  533. fail "objcopy ($testname)"
  534. return
  535. }
  536. set got [remote_exec host "$OBJDUMP -W ${copyfile}.o" "" "/dev/null" "objdump.out"]
  537. if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
  538. fail "$testname (reason: unexpected output)"
  539. send_log $got
  540. send_log "\n"
  541. return
  542. }
  543. if { [regexp_diff objdump.out $srcdir/$subdir/dw2-3.W] } then {
  544. fail "$testname"
  545. } else {
  546. pass "$testname"
  547. }
  548. }
  549. if { ([istarget "x86_64-*-elf*"]
  550. || [istarget "x86_64-*-linux*"]) } {
  551. set testname "Convert x86-64 object with zlib-gabi to x32 (1)"
  552. convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64"
  553. set testname "Convert x86-64 object with zlib-gabi to x32 (2)"
  554. convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
  555. set testname "Convert x86-64 object with zlib-gabi to x32 (3)"
  556. convert_test "$testname" "--compress-debug-sections=zlib-gabi --64" "-O elf32-x86-64 --decompress-debug-sections"
  557. set testname "Convert x86-64 object with zlib-gnu to x32 (1)"
  558. convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64"
  559. set testname "Convert x86-64 object with zlib-gnu to x32 (2)"
  560. convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
  561. set testname "Convert x86-64 object with zlib-gnu to x32 (3)"
  562. convert_test "$testname" "--compress-debug-sections=zlib-gnu --64" "-O elf32-x86-64 --decompress-debug-sections"
  563. set testname "Convert x86-64 object to x32 (1)"
  564. convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64"
  565. set testname "Convert x86-64 object to x32 (2)"
  566. convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gabi"
  567. set testname "Convert x86-64 object to x32 (3)"
  568. convert_test "$testname" "--nocompress-debug-sections --64" "-O elf32-x86-64 --compress-debug-sections=zlib-gnu"
  569. set testname "Convert x32 object with zlib-gabi to x86-64 (1)"
  570. convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64"
  571. set testname "Convert x32 object with zlib-gabi to x86-64 (2)"
  572. convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
  573. set testname "Convert x32 object with zlib-gabi to x86-64 (3)"
  574. convert_test "$testname" "--compress-debug-sections=zlib-gabi --x32" "-O elf64-x86-64 --decompress-debug-sections"
  575. set testname "Convert x32 object with zlib-gnu to x86-64 (1)"
  576. convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64"
  577. set testname "Convert x32 object with zlib-gnu to x86-64 (2)"
  578. convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
  579. set testname "Convert x32 object with zlib-gnu to x86-64 (3)"
  580. convert_test "$testname" "--compress-debug-sections=zlib-gnu --x32" "-O elf64-x86-64 --decompress-debug-sections"
  581. set testname "Convert x32 object to x86-64 (1)"
  582. convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64"
  583. set testname "Convert x32 object to x86-64 (2)"
  584. convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gabi"
  585. set testname "Convert x32 object to x86-64 (3)"
  586. convert_test "$testname" "--nocompress-debug-sections --x32" "-O elf64-x86-64 --compress-debug-sections=zlib-gnu"
  587. }