Is there a way to make objdump read from STDIN instead of a file?
In my specific case, I want to use it to dump what I echo
.
I don't want to involve any file...
Is there a way to make objdump
read from STDIN
instead?
You can't. There is no way around that, you will have to use the temporary file.
Source file readelf.c has this unconditional check (in binutils 2.22-8 at least) before even attempting to open the file:
if (! S_ISREG (statbuf.st_mode))
{
error (_("'%s' is not an ordinary file\n"), file_name);
return 1;
}
So if the file is anything but regular file (like symlink, or char device as in case of /dev/stdin
, /proc/self/fd/*
, etc.) it won't work.
Alternatively, you could modify the source and use modified objdump, but there goes your portability.
you can always do
objdump -d /dev/stdin < t2.o
or
cat t2.o | objdump -d /dev/stdin
sample
[root@myhost cc]# objdump -h /dev/stdin < t2.o
/dev/stdin: file format elf64-x86-64
Sections: Idx Name Size VMA LMA
File off Algn 0 .group 00000008 0000000000000000 0000000000000000 00000040 2**2 CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD