PERFORCE change 207125 for review
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Wed Feb 29 22:45:03 UTC 2012
http://p4web.freebsd.org/@@207125?ac=10
Change 207125 by gonzo at gonzo_thinkpad on 2012/02/29 22:44:57
- Swap bytes only if really required
Affected files ...
.. //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/output.c#3 edit
Differences ...
==== //depot/projects/dtrace-mips/cddl/contrib/opensolaris/tools/ctf/cvt/output.c#3 (text+ko) ====
@@ -730,10 +730,12 @@
struct stat st;
Elf *elf = NULL;
Elf *telf = NULL;
+ GElf_Ehdr ehdr;
caddr_t data;
size_t len;
int fd = -1;
int tfd = -1;
+ int byteorder;
(void) elf_version(EV_CURRENT);
if ((fd = open(curname, O_RDONLY)) < 0 || fstat(fd, &st) < 0)
@@ -746,6 +748,22 @@
if ((telf = elf_begin(tfd, ELF_C_WRITE, NULL)) == NULL)
elfterminate(curname, "Cannot write");
+ if (gelf_getehdr(elf, &ehdr)) {
+#if BYTE_ORDER == _BIG_ENDIAN
+ byteorder = ELFDATA2MSB;
+#else
+ byteorder = ELFDATA2LSB;
+#endif
+ /*
+ * If target and host has the same byte order
+ * clear byte swapping request
+ */
+ if (ehdr.e_ident[EI_DATA] == byteorder)
+ flags &= ~CTF_SWAP_BYTES;
+ }
+ else
+ elfterminate(curname, "Failed to get EHDR");
+
data = make_ctf_data(td, elf, curname, &len, flags);
write_file(elf, curname, telf, newname, data, len, flags);
free(data);
More information about the p4-projects
mailing list