IA-64 Porting to Linux

IA-64 Porting to Linux

MichaelMichael TiemannTiemann CTOCTO RedRed Hat,Hat, Inc.Inc. FebruaryFebruary 16,16, 20002000 AgendaAgenda l Trillian,Trillian, GNUGNU andand CygnusCygnus // RedRed HatHat l PortingPorting toto IAIA--6464 LinuxLinux ––IAIA--6464 LinuxLinux (Your(Your Target)Target) CharacteristicsCharacteristics ––KnowKnow YourYour StartingStarting PointPoint ––PortingPorting Issues/ChecklistIssues/Checklist ––UsingUsing GNUGNU ToolsTools toto EaseEase PortingPorting – other helpful tools l CallCall toto actionaction What’sWhat’s GNU?GNU? l GGNUNU isis NNotot UUnix!nix! l NonNon--proprietary,proprietary, cooperativecooperative developmentdevelopment ofof tools,tools, applicationsapplications andand systemssystems – very efficient at creating very good peer- reviewed software – identical tools across many computer systems – naturally promotes portable software l OpenOpen sourcesource – implementations are publicly readable – excellent learning tool GNUGNU toolstools areare usedused byby 95%95% ofof allall LinuxLinux developers!!developers!! SomeSome GNUGNU HistoryHistory 1984: GNU project starts - emacs 1985: GNU Debugger GDB 1987: GCC and G++ 1989: First commercial GNU tools 1991: GCC 2.0, GDB 4.0 2000 1985 1990 1995 2000: GCC for IA-64, GCC 3.0, GDB 5.0 RedRed HatHat (C(Cygygnus)nus) TrillianTrillian EffortEffort l IAIA--6464 workwork startedstarted withwith HP’sHP’s initialinitial portport ofof GCCGCC compilercompiler inin May’99May’99 l ContributedContributed GNUProGNUPro componentscomponents forfor thethe TrillianTrillian efforteffort ––gccgcc,, g++,g++, gas,gas, gldgld ––ProvidesProvides bothboth nativenative andand crosscross developmentdevelopment environmentsenvironments ––OnlyOnly LP64LP64 datadata modelmodel supportedsupported ––SupportsSupports developmentdevelopment ofof EFIEFI applicationsapplications IAIA--6464 GNUGNU toolstools –– FutureFuture WorkWork l What’sWhat’s inin thethe worksworks ––ExceptionException handlinghandling supportsupport ––AssemblerAssembler dependencydependency violationviolation supportsupport (DVLOC)(DVLOC) ––IntrinsicsIntrinsics (efficiency of assembly within C/C++ code) ––IAIA--6464 --specificspecific AssemblerAssembler directivesdirectives ––FullFull gdbgdb supportsupport IAIA--6464 GNUGNU toolstools –– FutureFuture WorkWork l CompilerCompiler OptimizationsOptimizations plannedplanned ––NewNew hardwarehardware pipelinepipeline modelmodel ––SchedulingScheduling ofof instructionsinstructions latencieslatencies ––BetterBetter looploop awareaware aliasalias analysisanalysis ––SoftwareSoftware pipeliningpipelining ––PredicationPredication ––SpeculationSpeculation IAIA--6464 UNIXUNIX ABIABI WorkWork l Intel,Intel, SCO,SCO, HP,HP, IBM,IBM, SGI,SGI, SUN,SUN, RedRed Hat,Hat, VAVA LinuxLinux l AgreementsAgreements onon – Common object format - ELF and DWARF – Standardized ELF extensions for better code generation – String section – allows compressions of string table program wide – Extended number of sections – more optimizations to reduce program size – Standardized intrinsic functions to allow access processor features through from C/C++ programs – more… IAIA--6464 C++C++ ABIABI WorkWork l IAIA--6464 C++C++ ABIABI GroupGroup ––SGI,SGI, Intel,Intel, HP,HP, IBM,IBM, SUN,SUN, RedRed HatHat andand SCOSCO l AgreementsAgreements onon ––standardizedstandardized objectobject layoutslayouts ––commoncommon virtualvirtual tabletable implementationimplementation ––standardizedstandardized (and(and optimized)optimized) namename manglingmangling l AllowsAllows somesome C++C++ binariesbinaries fromfrom oneone UnixUnix versionversion toto anotheranother UNIXUNIX versionversion forfor IAIA--6464 platformsplatforms PortingPorting toto IAIA--6464 LinuxLinux EssenceEssence ofof IAIA--6464 LinuxLinux IAIA--6464 LinuxLinux asas seenseen byby youryour code:code: l LP64LP64 – Like other 64-bit UNIX machines – ILP32 only via execution of x86 binaries – Caution: x86 and IA-64 processes can share data via shared memory, files, sockets, ... l StandardsStandards compliantcompliant (mostly)(mostly) – ISO/ANSI C, C++ (ISO Standards C90 and C99) – most UNIX/98 APIs EssenceEssence ofof IAIA--6464 LinuxLinux l littlelittle--endianendian (by(by default)default) ––nono bigbig--endianendian supportsupport l C/C++C/C++ prepre--definesdefines youyou cancan use:use: – established at compile time: __unix, __linux, __ia64, __LP64, __ELF__, __GNUC__ – established by header #include files: __WORDSIZE (== 64) KnowKnow YourYour SourceSource CodeCode l IsIs youryour sourcesource ISO/ANSIISO/ANSI compliant?compliant? l WhatWhat datadata structuresstructures areare externallyexternally visiblevisible (files,(files, sockets,sockets, sharedshared memory,memory, pipes,pipes, ...)...) toto otherother architectures?architectures? l WhatWhat platformplatform portsports areaarea alreadyalready done?done? l IsIs youryour sourcesource toto bebe builtbuilt onon bothboth UNIXUNIX andand Windows?Windows? PortingPorting toto IAIA--6464 LinuxLinux l IfIf youyou areare startingstarting fromfrom Windows*…Windows*… ––SetSet goalsgoals forfor LinuxLinux functionalityfunctionality ––PickPick toolstools andand toolkitstoolkits forfor LinuxLinux ––UseUse CC runtimeruntime librarylibrary andand POSIXPOSIX--likelike functionsfunctions insteadinstead ofof proprietaryproprietary MSMS interfacesinterfaces – Can use cygwin.dll as a bridge on IA-32 Linux Porting to IA-32 Linux first is recommended, but you can port to IA-64 Linux directly * All trademarks and brands are the property of their respective owners PortingPorting toto IAIA--6464 LinuxLinux l Guidelines:Guidelines: – Involves mostly recompiling if your source is already 64-bit clean – common object file format: ELF. All Unices will use it (no XCOFF, no SOM) – standardized ELF extensions allow better object generation. E.g. – the string section will allow compression of string table program-wide – the extended number of sections will allow putting functions (esp C++) in different sections – common binary format allows to develop tools usable for all different Unix platforms PortingPorting toto IAIA--6464 LinuxLinux l StepStep 1:1: GetGet GNUProGNUPro forfor IAIA--3232 LinuxLinux l StepStep 2:2: PortPort appsapps toto IAIA--3232 LinuxLinux ––UseUse -Wall -Wconversion -Wsign-compare l StepStep 3:3: CleanupCleanup ––pointer/integerpointer/integer warningswarnings ––signed/unsignedsigned/unsigned warningswarnings l StepStep 4:4: ReconfigureReconfigure andand recompilerecompile ChallenChallenggee ofof PortablePortable CodeCode l LegacyLegacy codecode oftenoften ignoresignores portabilityportability issuesissues l ManyMany programmersprogrammers areare simplysimply notnot taughttaught toto writewrite portableportable softwaresoftware l WritingWriting andand maintainingmaintaining portableportable softwaresoftware isis challenging,challenging, butbut worthworth itit GNUGNU SoftwareSoftware isis exemplary…exemplary… learnlearn fromfrom it!it! WritingWriting PortablePortable SoftwareSoftware l FollowFollow GNUGNU guidelinesguidelines ––WriteWrite codecode toto bebe ableable toto compilecompile withwith ISOISO CC oror ISOISO C++C++ compilerscompilers ––ConfigurationConfiguration // supportsupport packagespackages forfor compatibilitycompatibility – autoconf, automake, libtool l Example:Example: GNUGNU ‘hello’‘hello’ ––GNUGNU codingcoding standardsstandards ––InternationalizationInternationalization supportsupport PortingPorting RulesRules forfor IAIA--6464 l DODO ––UseUse #include#include toto getget systemsystem datadata typestypes l DON’TDON’T ––declaredeclare thingsthings youyou don'tdon't definedefine (required(required byby ISOISO C)C) l NEVERNEVER ––declaredeclare aa structurestructure thethe systemsystem definesdefines PortingPorting ChecklistChecklist l FixFix castscasts thatthat cancan truncatetruncate (int)&xyz, (long)&xyz ⇒ (uintptr_t)&xyz l UseUse sizeofsizeof()() andand offsetofoffsetof()() ––hardhard--codedcoded numbersnumbers -- ““44”” -- don’tdon’t portport ––n.b.n.b. argsargs toto mallocmalloc()(),, pointerpointer arithmeticarithmetic l UseUse size_tsize_t insteadinstead ofof intint oror longlong int ln= strlen(…); ⇒ size_t ln= str… ––otherother revisedrevised APIsAPIs PortingPorting ChecklistChecklist l UseUse sizedsized typestypes forfor externalexternal structuresstructures ––ISO/ANSIISO/ANSI datadata typestypes struct on_disk { int reclen; … ⇒ struct on_disk { int32_t reclen; … ––alsoalso forfor “on“on--wire”wire” andand sharedshared memorymemory structstructss l AccommodateAccommodate packingpacking differencesdifferences ––IAIA--6464 defaultsdefaults toto “natural“natural alignment”alignment” ––useuse ##pragmapragmass forfor sharedshared legacylegacy structuresstructures PortingPorting ChecklistChecklist l ReviseRevise printfprintf()(),, scanfscanf()() specifiersspecifiers “%08lX”,&foo) ⇒ (“%p”,…; “%d” ⇒ “%ld”; … l #error#error casecase atat endend ofof ##ifdefifdef chainschains ––preventsprevents unexpected/silentunexpected/silent useuse ofof somesome defaultdefault casecase … #elif defined(__ia64) … #else #error Update for new platform! #endif PortingPorting ChecklistChecklist l UseUse APIAPI callscalls toto getget systemsystem paramsparams getpagesize(), sysconf(_SC_CLK_TICK) l UseUse headerheader filefile mnemonicsmnemonics SEEK_END (not 2), INT_MIN (not -2147483648)) l InlineInline assemblyassembly mustmust bebe rere--writtenwritten OtherOther thingsthings youyou cancan dodo l SortSort youryour structuresstructures – Always optimize for speed and not space – Put the structure elements together that

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    35 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us