1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/reorder/addrs2text.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,33 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/* 1.9 + 1.10 + Converts a binary stream of address references to a text stream, 1.11 + hexadecimal, newline separated. 1.12 + 1.13 + */ 1.14 + 1.15 +#include <stdio.h> 1.16 +#include <unistd.h> 1.17 + 1.18 +int 1.19 +main(int argc, char *argv[]) 1.20 +{ 1.21 + unsigned int buf[1024]; 1.22 + ssize_t cb; 1.23 + 1.24 + while ((cb = read(STDIN_FILENO, buf, sizeof buf)) > 0) { 1.25 + if (cb % sizeof buf[0]) 1.26 + fprintf(stderr, "unaligned read\n"); 1.27 + 1.28 + unsigned int *addr = buf; 1.29 + unsigned int *limit = buf + (cb / 4); 1.30 + 1.31 + for (; addr < limit; ++addr) 1.32 + printf("%x\n", *addr); 1.33 + } 1.34 + 1.35 + return 0; 1.36 +}