Bug 3721 - Add ISA <-> Elf map, eliminate switch
Summary: Add ISA <-> Elf map, eliminate switch
Status: RESOLVED FIXED
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Tim Moore
URL:
Keywords:
Depends on:
Blocks: 2234 3387
  Show dependency treegraph
 
Reported: 2006-12-14 16:09 UTC by Andrew Cagney
Modified: 2007-02-15 13:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Cagney 2006-12-14 16:09:29 UTC
The file IsaFactory contains:

        ElfEHeader header = elfFile.getEHeader();
        switch (header.machine)
          {
          case ElfEMachine.EM_386:
            {
              if (frysk.core.Build.BUILD_ARCH.equals("i686"))
                return LinuxIa32.isaSingleton ();
              else
                return LinuxIa32On64.isaSingleton();
            }
          case ElfEMachine.EM_PPC:
            {
              // Assume we do not build 32-bit frysk on ppc64.
              if (frysk.core.Build.BUILD_ARCH.equals("powerpc64"))
                return LinuxPPC32On64.isaSingleton ();
              else
                return LinuxPPC.isaSingleton ();
            }
          case ElfEMachine.EM_PPC64:
            return LinuxPPC64.isaSingleton ();
          case ElfEMachine.EM_X86_64:
            return LinuxX8664.isaSingleton ();
          default:
            throw new TaskException("Unknown machine type " + header.machine);
          }

instead the IsaFactory (called ElfIsa????) should contain a hash table mapping
Elf.MACHINE/Elf.ENDIAN/Elf.WORDSIZE <-> a corresponding ISA object and then use
that.

That way, given an ISA, the corresponding Elf info can be found - see fcore; and
given the Elf info the corresponding ISA can be found - see the existing code.
Comment 1 Tim Moore 2007-02-15 13:47:00 UTC
Fixed with revision 1.11 of IsaFactory.java and other changes.