This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Use readelf to check 64 bit ELF.
- From: "H. J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Mon, 29 Sep 2003 15:27:04 -0700
- Subject: PATCH: Use readelf to check 64 bit ELF.
There is no need to hardcode 64 bit ELF. We can use readelf to check it
out. I will check in this patch shortly.
H.J.
---
2003-09-29 H.J. Lu <hongjiu.lu@intel.com>
* ld-scripts/phdrs.exp: Use is_elf_format. Use readelf to check
64 bit ELF.
--- ld-scripts/phdrs.exp.elf64 2002-07-30 14:02:56.000000000 -0700
+++ ld-scripts/phdrs.exp 2003-09-29 14:33:50.000000000 -0700
@@ -18,20 +18,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# PHDRS is only meaningful for ELF.
-if { ![istarget *-*-sysv4*] \
- && ![istarget *-*-unixware*] \
- && ![istarget *-*-elf*] \
- && ![istarget *-*-eabi*] \
- && ![istarget hppa*64*-*-hpux*] \
- && ![istarget *-*-linux*] \
- && ![istarget *-*-irix5*] \
- && ![istarget *-*-irix6*] \
- && ![istarget *-*-solaris2*] } {
- return
-}
-
-if { [istarget *-*-linux*aout*] \
- || [istarget *-*-linux*oldld*] } {
+if ![is_elf_format] {
return
}
@@ -48,11 +35,22 @@ set phdrs_regexp \
".*Program Header:.*PHDR *off *0x00*34 *vaddr *0x00*800034 *paddr *0x00*800034.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags r-x.*LOAD *off *0x0\[0-9a-f\]* *vaddr *0x00*80*\[0-9a-f\]* *paddr *0x00*80*\[0-9a-f\]*.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags *rw-.*"
# On a 64 bit ELF format, we need different numbers.
-if { [istarget alpha*-*-*] || [istarget "ia64*-*-*"]
- || [istarget "hppa*64*-*-*"] || [istarget "x86_64*-*-*"]
- || [istarget "s390x*-*-*"] || [istarget "sparc64*-*-*"]
- || [istarget "powerpc64*-*-*"] || [istarget "*-*-*elf64*"] } then {
- set phdrs_regexp \
+global READELF
+global READELFFLAGS
+set readelf_size ""
+catch "exec $READELF $READELFFLAGS -h tmpdir/phdrs.o > readelf.out" got
+if ![string match "" $got] then {
+ unresolved $testname
+ return
+}
+if { ! [regexp "\n\[ \]*Class:\[ \]*ELF(\[0-9\]+)\n" \
+ [file_contents readelf.out] nil readelf_size] } {
+ unresolved $testname
+ return
+}
+
+if { $readelf_size == "64" } {
+ set phdrs_regexp \
".*Program Header:.*PHDR *off *0x00*40 *vaddr *0x00*800040 *paddr *0x00*800040.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* flags r--.*LOAD *off *0x00* *vaddr *0x00*800000 *paddr *0x00*800000.*filesz *0x00*\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags r-x.*LOAD *off *0x0\[0-9a-f\]* *vaddr *0x00*80*\[0-9a-f\]* *paddr *0x00*80*\[0-9a-f\]*.*filesz *0x0\[0-9a-f\]* *memsz *0x0\[0-9a-f\]* *flags *rw-.*"
}