uClibc-0.9.28-ldso.patch 162 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190
  1. diff -urN uClibc-0.9.28.orig/include/elf.h uClibc-0.9.28/include/elf.h
  2. --- uClibc-0.9.28.orig/include/elf.h 2006-05-02 10:47:27.000000000 -0600
  3. +++ uClibc-0.9.28/include/elf.h 2006-04-28 00:14:35.000000000 -0600
  4. @@ -142,6 +142,7 @@
  5. #define ELFOSABI_HPUX 1 /* HP-UX */
  6. #define ELFOSABI_NETBSD 2 /* NetBSD. */
  7. #define ELFOSABI_LINUX 3 /* Linux. */
  8. +#define ELFOSABI_HURD 4 /* GNU/Hurd */
  9. #define ELFOSABI_SOLARIS 6 /* Sun Solaris. */
  10. #define ELFOSABI_AIX 7 /* IBM AIX. */
  11. #define ELFOSABI_IRIX 8 /* SGI Irix. */
  12. @@ -149,6 +150,9 @@
  13. #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */
  14. #define ELFOSABI_MODESTO 11 /* Novell Modesto. */
  15. #define ELFOSABI_OPENBSD 12 /* OpenBSD. */
  16. +#define ELFOSABI_OPENVMS 13 /* OpenVMS */
  17. +#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
  18. +#define ELFOSABI_AROS 15 /* Amiga Research OS */
  19. #define ELFOSABI_ARM 97 /* ARM */
  20. #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
  21. @@ -177,6 +181,7 @@
  22. #define EM_386 3 /* Intel 80386 */
  23. #define EM_68K 4 /* Motorola m68k family */
  24. #define EM_88K 5 /* Motorola m88k family */
  25. +#define EM_486 6 /* Intel 80486 *//* Reserved for future use */
  26. #define EM_860 7 /* Intel 80860 */
  27. #define EM_MIPS 8 /* MIPS R3000 big-endian */
  28. #define EM_S370 9 /* IBM System/370 */
  29. @@ -193,7 +198,8 @@
  30. #define EM_V800 36 /* NEC V800 series */
  31. #define EM_FR20 37 /* Fujitsu FR20 */
  32. #define EM_RH32 38 /* TRW RH-32 */
  33. -#define EM_RCE 39 /* Motorola RCE */
  34. +#define EM_MCORE 39 /* Motorola M*Core */ /* May also be taken by Fujitsu MMA */
  35. +#define EM_RCE 39 /* Old name for MCore */
  36. #define EM_ARM 40 /* ARM */
  37. #define EM_FAKE_ALPHA 41 /* Digital Alpha */
  38. #define EM_SH 42 /* Renesas SH */
  39. @@ -248,18 +254,105 @@
  40. #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
  41. #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
  42. #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */
  43. +#define EM_IP2K 101 /* Ubicom IP2022 micro controller */
  44. +#define EM_CR 103 /* National Semiconductor CompactRISC */
  45. +#define EM_MSP430 105 /* TI msp430 micro controller */
  46. +#define EM_BLACKFIN 106 /* Analog Devices Blackfin */
  47. +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
  48. +#define EM_CRX 114 /* National Semiconductor CRX */
  49. #define EM_NUM 95
  50. -/* If it is necessary to assign new unofficial EM_* values, please
  51. - pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
  52. - chances of collision with official or non-GNU unofficial values. */
  53. +/* If it is necessary to assign new unofficial EM_* values, please pick large
  54. + random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
  55. + with official or non-GNU unofficial values.
  56. -/* Fujitsu FR-V. */
  57. + NOTE: Do not just increment the most recent number by one.
  58. + Somebody else somewhere will do exactly the same thing, and you
  59. + will have a collision. Instead, pick a random number.
  60. +
  61. + Normally, each entity or maintainer responsible for a machine with an
  62. + unofficial e_machine number should eventually ask registry@caldera.com for
  63. + an officially blessed number to be added to the list above. */
  64. +
  65. +/* picoJava */
  66. +#define EM_PJ_OLD 99
  67. +
  68. +/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */
  69. +#define EM_CYGNUS_POWERPC 0x9025
  70. +
  71. +/* Old version of Sparc v9, from before the ABI; this should be
  72. + removed shortly. */
  73. +#define EM_OLD_SPARCV9 11
  74. +
  75. +/* Old version of PowerPC, this should be removed shortly. */
  76. +#define EM_PPC_OLD 17
  77. +
  78. +/* (Deprecated) Temporary number for the OpenRISC processor. */
  79. +#define EM_OR32 0x8472
  80. +
  81. +/* Renesas M32C and M16C. */
  82. +#define EM_M32C 0xFEB0
  83. +
  84. +/* Cygnus M32R ELF backend. Written in the absence of an ABI. */
  85. +#define EM_CYGNUS_M32R 0x9041
  86. +
  87. +/* old S/390 backend magic number. Written in the absence of an ABI. */
  88. +#define EM_S390_OLD 0xa390
  89. +
  90. +/* D10V backend magic number. Written in the absence of an ABI. */
  91. +#define EM_CYGNUS_D10V 0x7650
  92. +
  93. +/* D30V backend magic number. Written in the absence of an ABI. */
  94. +#define EM_CYGNUS_D30V 0x7676
  95. +
  96. +/* V850 backend magic number. Written in the absense of an ABI. */
  97. +#define EM_CYGNUS_V850 0x9080
  98. +
  99. +/* mn10200 and mn10300 backend magic numbers.
  100. + Written in the absense of an ABI. */
  101. +#define EM_CYGNUS_MN10200 0xdead
  102. +#define EM_CYGNUS_MN10300 0xbeef
  103. +
  104. +/* FR30 magic number - no EABI available. */
  105. +#define EM_CYGNUS_FR30 0x3330
  106. +
  107. +/* AVR magic number
  108. + Written in the absense of an ABI. */
  109. +#define EM_AVR_OLD 0x1057
  110. +
  111. +/* OpenRISC magic number
  112. + Written in the absense of an ABI. */
  113. +#define EM_OPENRISC_OLD 0x3426
  114. +
  115. +/* DLX magic number
  116. + Written in the absense of an ABI. */
  117. +#define EM_DLX 0x5aa5
  118. +
  119. +#define EM_XSTORMY16 0xad45
  120. +
  121. +/* FRV magic number - no EABI available??. */
  122. #define EM_CYGNUS_FRV 0x5441
  123. +/* Ubicom IP2xxx; no ABI */
  124. +#define EM_IP2K_OLD 0x8217
  125. +
  126. +#define EM_MT 0x2530 /* Morpho MT; no ABI */
  127. +
  128. +/* MSP430 magic number
  129. + Written in the absense everything. */
  130. +#define EM_MSP430_OLD 0x1059
  131. +
  132. +/* Vitesse IQ2000. */
  133. +#define EM_IQ2000 0xFEBA
  134. +
  135. +/* Old, unofficial value for Xtensa. */
  136. +#define EM_XTENSA_OLD 0xabc7
  137. +
  138. +/* Alpha backend magic number. Written in the absence of an ABI. */
  139. #define EM_ALPHA 0x9026
  140. -#define EM_NIOS32 0xfebb /* Altera Nios 32 */
  141. -#define EM_ALTERA_NIOS2 0x9ee5 /* Altera Nios II */
  142. +
  143. +/* NIOS magic number - no EABI available. */
  144. +#define EM_NIOS32 0xFEBB
  145. /* V850 backend magic number. Written in the absense of an ABI. */
  146. #define EM_CYGNUS_V850 0x9080
  147. @@ -2498,6 +2591,12 @@
  148. #define R_390_NUM 61
  149. +/* CRIS flags. */
  150. +#define EF_CRIS_VARIANT_MASK 0x0000000e
  151. +#define EF_CRIS_VARIANT_ANY_V0_V10 0x00000000
  152. +#define EF_CRIS_VARIANT_V32 0x00000002
  153. +#define EF_CRIS_VARIANT_COMMON_V10_V32 0x00000004
  154. +
  155. /* CRIS relocations. */
  156. #define R_CRIS_NONE 0
  157. #define R_CRIS_8 1
  158. @@ -2688,6 +2787,7 @@
  159. #define R_V850_NUM 25
  160. +/* Renesas H8/300 Relocations */
  161. #define R_H8_NONE 0
  162. #define R_H8_DIR32 1
  163. #define R_H8_DIR32_28 2
  164. @@ -2731,8 +2831,7 @@
  165. #define R_H8_DIR32A16 63
  166. #define R_H8_ABS32 65
  167. #define R_H8_ABS32A16 127
  168. -
  169. -/* Altera NIOS specific definitions. */
  170. +#define R_H8_NUM 128
  171. /* NIOS relocations. */
  172. #define R_NIOS_NONE 0
  173. diff -urN uClibc-0.9.28.orig/include/errno.h uClibc-0.9.28/include/errno.h
  174. --- uClibc-0.9.28.orig/include/errno.h 2006-05-02 10:47:27.000000000 -0600
  175. +++ uClibc-0.9.28/include/errno.h 2006-04-28 00:14:35.000000000 -0600
  176. @@ -43,9 +43,11 @@
  177. variable. This redeclaration using the macro still works, but it
  178. will be a function declaration without a prototype and may trigger
  179. a -Wstrict-prototypes warning. */
  180. +#ifndef __ASSEMBLER__
  181. #ifndef errno
  182. extern int errno;
  183. #endif
  184. +#endif
  185. #if 0 /*def __USE_GNU uClibc note: not supported */
  186. diff -urN uClibc-0.9.28.orig/ldso/Makefile uClibc-0.9.28/ldso/Makefile
  187. --- uClibc-0.9.28.orig/ldso/Makefile 2006-05-02 10:47:27.000000000 -0600
  188. +++ uClibc-0.9.28/ldso/Makefile 2006-04-28 00:14:35.000000000 -0600
  189. @@ -37,15 +37,12 @@
  190. LN_HEADERS := $(patsubst %, include/%, elf.h)
  191. LN_ARCH_HEADERS := $(patsubst %, include/%, dl-startup.h dl-syscalls.h dl-sysdep.h dl-debug.h)
  192. -HEADERS := $(LN_HEADERS) $(LN_ARCH_HEADERS) include/dl-progname.h
  193. +HEADERS := $(LN_HEADERS) $(LN_ARCH_HEADERS)
  194. headers: $(HEADERS)
  195. $(LN_HEADERS):
  196. $(LN) -fs $(TOPDIR)../$@ $@
  197. $(LN_ARCH_HEADERS):
  198. $(LN) -fs ../ldso/$(TARGET_ARCH)/$(patsubst include/%,%,$@) $@
  199. -include/dl-progname.h:
  200. - echo '#include "$(TARGET_ARCH)/elfinterp.c"' \
  201. - > include/dl-progname.h
  202. clean:
  203. set -e ; for d in $(DIRS) ; do $(MAKE) -C $$d $@ ; done
  204. diff -urN uClibc-0.9.28.orig/ldso/include/dl-defs.h uClibc-0.9.28/ldso/include/dl-defs.h
  205. --- uClibc-0.9.28.orig/ldso/include/dl-defs.h 2006-05-02 10:47:27.000000000 -0600
  206. +++ uClibc-0.9.28/ldso/include/dl-defs.h 2006-04-28 00:14:35.000000000 -0600
  207. @@ -1,6 +1,29 @@
  208. +/* vi: set sw=4 ts=4: */
  209. +/*
  210. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  211. + *
  212. + * GNU Lesser General Public License version 2.1 or later.
  213. + */
  214. +
  215. #ifndef _LD_DEFS_H
  216. #define _LD_DEFS_H
  217. +#define FLAG_ANY -1
  218. +#define FLAG_TYPE_MASK 0x00ff
  219. +#define FLAG_LIBC4 0x0000
  220. +#define FLAG_ELF 0x0001
  221. +#define FLAG_ELF_LIBC5 0x0002
  222. +#define FLAG_ELF_LIBC6 0x0003
  223. +#define FLAG_ELF_UCLIBC 0x0004
  224. +#define FLAG_REQUIRED_MASK 0xff00
  225. +#define FLAG_SPARC_LIB64 0x0100
  226. +#define FLAG_IA64_LIB64 0x0200
  227. +#define FLAG_X8664_LIB64 0x0300
  228. +#define FLAG_S390_LIB64 0x0400
  229. +#define FLAG_POWERPC_LIB64 0x0500
  230. +#define FLAG_MIPS64_LIBN32 0x0600
  231. +#define FLAG_MIPS64_LIBN64 0x0700
  232. +
  233. #define LIB_ANY -1
  234. #define LIB_DLL 0
  235. #define LIB_ELF 1
  236. diff -urN uClibc-0.9.28.orig/ldso/include/dl-elf.h uClibc-0.9.28/ldso/include/dl-elf.h
  237. --- uClibc-0.9.28.orig/ldso/include/dl-elf.h 2006-05-02 10:47:27.000000000 -0600
  238. +++ uClibc-0.9.28/ldso/include/dl-elf.h 2006-04-28 00:14:35.000000000 -0600
  239. @@ -1,3 +1,10 @@
  240. +/* vi: set sw=4 ts=4: */
  241. +/*
  242. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  243. + *
  244. + * GNU Lesser General Public License version 2.1 or later.
  245. + */
  246. +
  247. #ifndef LINUXELF_H
  248. #define LINUXELF_H
  249. diff -urN uClibc-0.9.28.orig/ldso/include/dl-hash.h uClibc-0.9.28/ldso/include/dl-hash.h
  250. --- uClibc-0.9.28.orig/ldso/include/dl-hash.h 2006-05-02 10:47:27.000000000 -0600
  251. +++ uClibc-0.9.28/ldso/include/dl-hash.h 2006-04-28 00:14:35.000000000 -0600
  252. @@ -1,3 +1,10 @@
  253. +/* vi: set sw=4 ts=4: */
  254. +/*
  255. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  256. + *
  257. + * GNU Lesser General Public License version 2.1 or later.
  258. + */
  259. +
  260. #ifndef _LD_HASH_H_
  261. #define _LD_HASH_H_
  262. @@ -32,15 +39,15 @@
  263. unsigned short usage_count;
  264. unsigned short int init_flag;
  265. unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
  266. - Elf32_Word nbucket;
  267. - Elf32_Word *elf_buckets;
  268. + Elf_Symndx nbucket;
  269. + Elf_Symndx *elf_buckets;
  270. struct init_fini_list *init_fini;
  271. struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
  272. /*
  273. * These are only used with ELF style shared libraries
  274. */
  275. - Elf32_Word nchain;
  276. - Elf32_Word *chains;
  277. + Elf_Symndx nchain;
  278. + Elf_Symndx *chains;
  279. unsigned long dynamic_info[DYNAMIC_SIZE];
  280. unsigned long n_phent;
  281. @@ -49,6 +56,9 @@
  282. ElfW(Addr) relro_addr;
  283. size_t relro_size;
  284. + dev_t st_dev; /* device */
  285. + ino_t st_ino; /* inode */
  286. +
  287. #ifdef __powerpc__
  288. /* this is used to store the address of relocation data words, so
  289. * we don't have to calculate it every time, which requires a divide */
  290. @@ -66,7 +76,6 @@
  291. extern struct elf_resolve * _dl_loaded_modules;
  292. extern struct dyn_elf * _dl_handles;
  293. -extern struct elf_resolve * _dl_check_hashed_files(const char * libname);
  294. extern struct elf_resolve * _dl_add_elf_hash_table(const char * libname,
  295. char * loadaddr, unsigned long * dynamic_info,
  296. unsigned long dynamic_addr, unsigned long dynamic_size);
  297. diff -urN uClibc-0.9.28.orig/ldso/include/dl-string.h uClibc-0.9.28/ldso/include/dl-string.h
  298. --- uClibc-0.9.28.orig/ldso/include/dl-string.h 2006-05-02 10:47:27.000000000 -0600
  299. +++ uClibc-0.9.28/ldso/include/dl-string.h 2006-04-28 00:14:35.000000000 -0600
  300. @@ -1,9 +1,24 @@
  301. +/* vi: set sw=4 ts=4: */
  302. +/*
  303. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  304. + *
  305. + * GNU Lesser General Public License version 2.1 or later.
  306. + */
  307. +
  308. #ifndef _LINUX_STRING_H_
  309. #define _LINUX_STRING_H_
  310. -#include <dl-sysdep.h> // for do_rem
  311. +#include <dl-sysdep.h> /* for do_rem */
  312. #include <features.h>
  313. +/* provide some sane defaults */
  314. +#ifndef do_rem
  315. +# define do_rem(result, n, base) ((result) = (n) % (base))
  316. +#endif
  317. +#ifndef do_div_10
  318. +# define do_div_10(result, remain) ((result) /= 10)
  319. +#endif
  320. +
  321. static size_t _dl_strlen(const char * str);
  322. static char *_dl_strcat(char *dst, const char *src);
  323. static char * _dl_strcpy(char * dst,const char *src);
  324. @@ -26,8 +41,8 @@
  325. static __always_inline size_t _dl_strlen(const char * str)
  326. {
  327. register const char *ptr = (char *) str-1;
  328. -
  329. - while (*++ptr);
  330. + while (*++ptr)
  331. + ;/* empty */
  332. return (ptr - str);
  333. }
  334. @@ -49,7 +64,8 @@
  335. register char *ptr = dst;
  336. dst--;src--;
  337. - while ((*++dst = *++src) != 0);
  338. + while ((*++dst = *++src) != 0)
  339. + ;/* empty */
  340. return ptr;
  341. }
  342. @@ -63,8 +79,7 @@
  343. c2 = (unsigned char) *++s2;
  344. if (c1 == '\0')
  345. return c1 - c2;
  346. - }
  347. - while (c1 == c2);
  348. + } while (c1 == c2);
  349. return c1 - c2;
  350. }
  351. @@ -98,43 +113,41 @@
  352. return 0;
  353. }
  354. -static inline char * _dl_strrchr(const char *str, int c)
  355. +static __always_inline char * _dl_strrchr(const char *str, int c)
  356. {
  357. - register char *prev = 0;
  358. - register char *ptr = (char *) str-1;
  359. + register char *prev = 0;
  360. + register char *ptr = (char *) str-1;
  361. - while (*++ptr != '\0') {
  362. - if (*ptr == c)
  363. - prev = ptr;
  364. - }
  365. - if (c == '\0')
  366. - return(ptr);
  367. - return(prev);
  368. + while (*++ptr != '\0') {
  369. + if (*ptr == c)
  370. + prev = ptr;
  371. + }
  372. + if (c == '\0')
  373. + return(ptr);
  374. + return(prev);
  375. }
  376. -static inline char * _dl_strstr(const char *s1, const char *s2)
  377. +static __always_inline char * _dl_strstr(const char *s1, const char *s2)
  378. {
  379. - register const char *s = s1;
  380. - register const char *p = s2;
  381. + register const char *s = s1;
  382. + register const char *p = s2;
  383. - do {
  384. - if (!*p) {
  385. - return (char *) s1;;
  386. - }
  387. - if (*p == *s) {
  388. - ++p;
  389. - ++s;
  390. - } else {
  391. - p = s2;
  392. - if (!*s) {
  393. - return NULL;
  394. - }
  395. - s = ++s1;
  396. - }
  397. - } while (1);
  398. + do {
  399. + if (!*p)
  400. + return (char *) s1;;
  401. + if (*p == *s) {
  402. + ++p;
  403. + ++s;
  404. + } else {
  405. + p = s2;
  406. + if (!*s)
  407. + return NULL;
  408. + s = ++s1;
  409. + }
  410. + } while (1);
  411. }
  412. -static inline void * _dl_memcpy(void * dst, const void * src, size_t len)
  413. +static __always_inline void * _dl_memcpy(void * dst, const void * src, size_t len)
  414. {
  415. register char *a = dst-1;
  416. register const char *b = src-1;
  417. @@ -163,27 +176,28 @@
  418. /* Will generate smaller and faster code due to loop unrolling.*/
  419. static __always_inline void * _dl_memset(void *to, int c, size_t n)
  420. {
  421. - unsigned long chunks;
  422. - unsigned long *tmp_to;
  423. + unsigned long chunks;
  424. + unsigned long *tmp_to;
  425. unsigned char *tmp_char;
  426. - chunks = n / 4;
  427. - tmp_to = to + n;
  428. - c = c << 8 | c;
  429. - c = c << 16 | c;
  430. - if (!chunks)
  431. - goto lessthan4;
  432. - do {
  433. - *--tmp_to = c;
  434. - } while (--chunks);
  435. - lessthan4:
  436. - n = n % 4;
  437. - if (!n ) return to;
  438. - tmp_char = (unsigned char *)tmp_to;
  439. - do {
  440. - *--tmp_char = c;
  441. - } while (--n);
  442. - return to;
  443. + chunks = n / 4;
  444. + tmp_to = to + n;
  445. + c = c << 8 | c;
  446. + c = c << 16 | c;
  447. + if (!chunks)
  448. + goto lessthan4;
  449. + do {
  450. + *--tmp_to = c;
  451. + } while (--chunks);
  452. +lessthan4:
  453. + n = n % 4;
  454. + if (!n)
  455. + return to;
  456. + tmp_char = (unsigned char *)tmp_to;
  457. + do {
  458. + *--tmp_char = c;
  459. + } while (--n);
  460. + return to;
  461. }
  462. #else
  463. static __always_inline void * _dl_memset(void * str,int c,size_t len)
  464. @@ -225,10 +239,10 @@
  465. char *p = &local[22];
  466. *--p = '\0';
  467. do {
  468. - char temp;
  469. - do_rem(temp, i, 10);
  470. - *--p = '0' + temp;
  471. - i /= 10;
  472. + char temp;
  473. + do_rem(temp, i, 10);
  474. + *--p = '0' + temp;
  475. + do_div_10(i, temp);
  476. } while (i > 0);
  477. return p;
  478. }
  479. @@ -242,9 +256,9 @@
  480. do {
  481. char temp = i & 0xf;
  482. if (temp <= 0x09)
  483. - *--p = '0' + temp;
  484. + *--p = '0' + temp;
  485. else
  486. - *--p = 'a' - 0x0a + temp;
  487. + *--p = 'a' - 0x0a + temp;
  488. i >>= 4;
  489. } while (i > 0);
  490. *--p = 'x';
  491. @@ -270,8 +284,8 @@
  492. /* On some arches constant strings are referenced through the GOT.
  493. * This requires that load_addr must already be defined... */
  494. -#if defined(mc68000) || defined(__arm__) || defined(__mips__) \
  495. - || defined(__sh__) || defined(__powerpc__)
  496. +#if defined(mc68000) || defined(__arm__) || defined(__thumb__) || \
  497. + defined(__mips__) || defined(__sh__) || defined(__powerpc__)
  498. # define CONSTANT_STRING_GOT_FIXUP(X) \
  499. if ((X) < (const char *) load_addr) (X) += load_addr
  500. # define NO_EARLY_SEND_STDERR
  501. @@ -318,7 +332,7 @@
  502. do { \
  503. do_rem(v, (X), 10); \
  504. *--tmp2 = '0' + v; \
  505. - (X) /= 10; \
  506. + do_div_10((X), v); \
  507. } while ((X) > 0); \
  508. _dl_write(2, tmp2, tmp1 - tmp2 + sizeof(tmp) - 1); \
  509. }
  510. diff -urN uClibc-0.9.28.orig/ldso/include/dl-syscall.h uClibc-0.9.28/ldso/include/dl-syscall.h
  511. --- uClibc-0.9.28.orig/ldso/include/dl-syscall.h 2006-05-02 10:47:27.000000000 -0600
  512. +++ uClibc-0.9.28/ldso/include/dl-syscall.h 2006-04-28 00:14:35.000000000 -0600
  513. @@ -1,3 +1,10 @@
  514. +/* vi: set sw=4 ts=4: */
  515. +/*
  516. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  517. + *
  518. + * GNU Lesser General Public License version 2.1 or later.
  519. + */
  520. +
  521. #ifndef _LD_SYSCALL_H_
  522. #define _LD_SYSCALL_H_
  523. @@ -12,9 +19,8 @@
  524. #include <bits/kernel_stat.h>
  525. #include <bits/kernel_types.h>
  526. -
  527. /* _dl_open() parameters */
  528. -#define O_RDONLY 0x0000
  529. +#define O_RDONLY 00
  530. #define O_WRONLY 01
  531. #define O_RDWR 02
  532. #define O_CREAT 0100
  533. @@ -39,18 +45,6 @@
  534. #define S_IWRITE 0200 /* Write by owner. */
  535. #define S_IEXEC 0100 /* Execute by owner. */
  536. -/* Stuff for _dl_mmap */
  537. -#if 0
  538. -#define MAP_FAILED ((void *) -1)
  539. -#define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
  540. -#else
  541. -#ifndef _dl_MAX_ERRNO
  542. -#define _dl_MAX_ERRNO 4096
  543. -#endif
  544. -#define _dl_mmap_check_error(__res) \
  545. - (((long)__res) < 0 && ((long)__res) >= -_dl_MAX_ERRNO)
  546. -#endif
  547. -
  548. /* Here are the definitions for some syscalls that are used
  549. @@ -66,54 +60,125 @@
  550. static inline _syscall1(int, _dl_close, int, fd);
  551. #define __NR__dl_open __NR_open
  552. -static inline _syscall3(int, _dl_open, const char *, fn, int, flags, __kernel_mode_t, mode);
  553. +static inline _syscall3(int, _dl_open, const char *, fn, int, flags,
  554. + __kernel_mode_t, mode);
  555. #define __NR__dl_write __NR_write
  556. static inline _syscall3(unsigned long, _dl_write, int, fd,
  557. - const void *, buf, unsigned long, count);
  558. + const void *, buf, unsigned long, count);
  559. #define __NR__dl_read __NR_read
  560. static inline _syscall3(unsigned long, _dl_read, int, fd,
  561. - const void *, buf, unsigned long, count);
  562. + const void *, buf, unsigned long, count);
  563. #define __NR__dl_mprotect __NR_mprotect
  564. -static inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot);
  565. +static inline _syscall3(int, _dl_mprotect, const void *, addr,
  566. + unsigned long, len, int, prot);
  567. #define __NR__dl_stat __NR_stat
  568. -static inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf);
  569. +static inline _syscall2(int, _dl_stat, const char *, file_name,
  570. + struct stat *, buf);
  571. +
  572. +#define __NR__dl_fstat __NR_fstat
  573. +static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
  574. #define __NR__dl_munmap __NR_munmap
  575. static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
  576. +#ifdef __NR_getxuid
  577. +# define __NR_getuid __NR_getxuid
  578. +#endif
  579. #define __NR__dl_getuid __NR_getuid
  580. static inline _syscall0(uid_t, _dl_getuid);
  581. +#ifndef __NR_geteuid
  582. +# define __NR_geteuid __NR_getuid
  583. +#endif
  584. #define __NR__dl_geteuid __NR_geteuid
  585. static inline _syscall0(uid_t, _dl_geteuid);
  586. +#ifdef __NR_getxgid
  587. +# define __NR_getgid __NR_getxgid
  588. +#endif
  589. #define __NR__dl_getgid __NR_getgid
  590. static inline _syscall0(gid_t, _dl_getgid);
  591. +#ifndef __NR_getegid
  592. +# define __NR_getegid __NR_getgid
  593. +#endif
  594. #define __NR__dl_getegid __NR_getegid
  595. static inline _syscall0(gid_t, _dl_getegid);
  596. +#ifdef __NR_getxpid
  597. +# define __NR_getpid __NR_getxpid
  598. +#endif
  599. #define __NR__dl_getpid __NR_getpid
  600. static inline _syscall0(gid_t, _dl_getpid);
  601. #define __NR__dl_readlink __NR_readlink
  602. -static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf, size_t, bufsiz);
  603. +static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
  604. + size_t, bufsiz);
  605. -#ifdef __NR_mmap
  606. -#ifdef MMAP_HAS_6_ARGS
  607. -#define __NR__dl_mmap __NR_mmap
  608. -static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
  609. - int, prot, int, flags, int, fd, off_t, offset);
  610. +#ifdef __UCLIBC_HAS_SSP__
  611. +# include <sys/time.h>
  612. +# define __NR__dl_gettimeofday __NR_gettimeofday
  613. +static inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv,
  614. +# ifdef __USE_BSD
  615. + struct timezone *, tz);
  616. +# else
  617. + void *, tz);
  618. +# endif
  619. +#endif
  620. +
  621. +
  622. +/* handle all the fun mmap intricacies */
  623. +#if (defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)) || !defined(__NR_mmap2)
  624. +# define _dl_MAX_ERRNO 4096
  625. +# define _dl_mmap_check_error(__res) \
  626. + (((long)__res) < 0 && ((long)__res) >= -_dl_MAX_ERRNO)
  627. #else
  628. -#define __NR__dl_mmap_real __NR_mmap
  629. -static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
  630. +# define MAP_FAILED ((void *) -1)
  631. +# define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
  632. +#endif
  633. +
  634. +/* first try mmap(), syscall6() style */
  635. +#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
  636. +
  637. +# define __NR__dl_mmap __NR_mmap
  638. +static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
  639. + int, prot, int, flags, int, fd, off_t, offset);
  640. +
  641. +/* then try mmap2() */
  642. +#elif defined(__NR_mmap2)
  643. +
  644. +# define __NR___syscall_mmap2 __NR_mmap2
  645. +static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
  646. + int, prot, int, flags, int, fd, off_t, offset);
  647. +
  648. +/* Some architectures always use 12 as page shift for mmap2() eventhough the
  649. + * real PAGE_SHIFT != 12. Other architectures use the same value as
  650. + * PAGE_SHIFT...
  651. + */
  652. +#ifndef MMAP2_PAGE_SHIFT
  653. +# define MMAP2_PAGE_SHIFT 12
  654. +#endif
  655. static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
  656. - int flags, int fd, unsigned long offset)
  657. + int flags, int fd, unsigned long offset)
  658. +{
  659. + if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
  660. + return MAP_FAILED;
  661. + return __syscall_mmap2(addr, size, prot, flags,
  662. + fd, (off_t) (offset >> MMAP2_PAGE_SHIFT));
  663. +}
  664. +
  665. +/* finally, fall back to mmap(), syscall1() style */
  666. +#elif defined(__NR_mmap)
  667. +
  668. +# define __NR__dl_mmap_real __NR_mmap
  669. +static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
  670. +static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
  671. + int flags, int fd, unsigned long offset)
  672. {
  673. unsigned long buffer[6];
  674. @@ -125,24 +190,9 @@
  675. buffer[5] = (unsigned long) offset;
  676. return (void *) _dl_mmap_real(buffer);
  677. }
  678. -#endif
  679. -#elif defined __NR_mmap2
  680. -#define __NR___syscall_mmap2 __NR_mmap2
  681. -static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
  682. - size_t, len, int, prot, int, flags, int, fd, off_t, offset);
  683. -/*always 12, even on architectures where PAGE_SHIFT != 12 */
  684. -#define MMAP2_PAGE_SHIFT 12
  685. -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
  686. - int flags, int fd, unsigned long offset)
  687. -{
  688. - if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
  689. - return MAP_FAILED;
  690. - return(__syscall_mmap2(addr, size, prot, flags,
  691. - fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
  692. -}
  693. +
  694. #else
  695. -#error "Your architecture doesn't seem to provide mmap() !?"
  696. +# error "Your architecture doesn't seem to provide mmap() !?"
  697. #endif
  698. #endif /* _LD_SYSCALL_H_ */
  699. -
  700. diff -urN uClibc-0.9.28.orig/ldso/include/dlfcn.h uClibc-0.9.28/ldso/include/dlfcn.h
  701. --- uClibc-0.9.28.orig/ldso/include/dlfcn.h 2006-05-02 10:47:27.000000000 -0600
  702. +++ uClibc-0.9.28/ldso/include/dlfcn.h 2006-04-28 00:14:35.000000000 -0600
  703. @@ -1,3 +1,10 @@
  704. +/* vi: set sw=4 ts=4: */
  705. +/*
  706. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  707. + *
  708. + * GNU Lesser General Public License version 2.1 or later.
  709. + */
  710. +
  711. /* User functions for run-time dynamic loading. libdl version */
  712. #ifndef _DLFCN_H
  713. #define _DLFCN_H 1
  714. diff -urN uClibc-0.9.28.orig/ldso/include/ldso.h uClibc-0.9.28/ldso/include/ldso.h
  715. --- uClibc-0.9.28.orig/ldso/include/ldso.h 2006-05-02 10:47:27.000000000 -0600
  716. +++ uClibc-0.9.28/ldso/include/ldso.h 2006-04-28 00:14:35.000000000 -0600
  717. @@ -1,3 +1,10 @@
  718. +/* vi: set sw=4 ts=4: */
  719. +/*
  720. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  721. + *
  722. + * GNU Lesser General Public License version 2.1 or later.
  723. + */
  724. +
  725. #ifndef _LDSO_H_
  726. #define _LDSO_H_
  727. @@ -20,13 +27,15 @@
  728. /* Pull in compiler and arch stuff */
  729. #include <stdlib.h>
  730. #include <stdarg.h>
  731. +#include <bits/wordsize.h>
  732. /* Pull in the arch specific type information */
  733. #include <sys/types.h>
  734. +/* Pull in the arch specific page size */
  735. +#include <bits/uClibc_page.h>
  736. +#define attribute_unused __attribute__ ((unused))
  737. /* Pull in the ldso syscalls and string functions */
  738. #include <dl-syscall.h>
  739. #include <dl-string.h>
  740. -/* Pull in the arch specific page size */
  741. -#include <bits/uClibc_page.h>
  742. /* Now the ldso specific headers */
  743. #include <dl-elf.h>
  744. #include <dl-hash.h>
  745. diff -urN uClibc-0.9.28.orig/ldso/include/unsecvars.h uClibc-0.9.28/ldso/include/unsecvars.h
  746. --- uClibc-0.9.28.orig/ldso/include/unsecvars.h 2006-05-02 10:47:27.000000000 -0600
  747. +++ uClibc-0.9.28/ldso/include/unsecvars.h 2006-04-28 00:14:35.000000000 -0600
  748. @@ -1,3 +1,10 @@
  749. +/* vi: set sw=4 ts=4: */
  750. +/*
  751. + * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
  752. + *
  753. + * GNU Lesser General Public License version 2.1 or later.
  754. + */
  755. +
  756. /*
  757. * Environment variable to be removed for SUID programs. The names are all
  758. * stuffed in a single string which means they have to be terminated with a
  759. @@ -5,22 +12,21 @@
  760. */
  761. #define UNSECURE_ENVVARS \
  762. - "LD_AOUT_PRELOAD\0" \
  763. - "LD_AOUT_LIBRARY_PATH\0" \
  764. "LD_PRELOAD\0" \
  765. "LD_LIBRARY_PATH\0" \
  766. "LD_DEBUG\0" \
  767. "LD_DEBUG_OUTPUT\0" \
  768. "LD_TRACE_LOADED_OBJECTS\0" \
  769. - "HOSTALIASES\0" \
  770. - "LOCALDOMAIN\0" \
  771. - "RES_OPTIONS\0" \
  772. "TMPDIR\0"
  773. /*
  774. + * LD_TRACE_LOADED_OBJECTS is not in glibc-2.3.5's unsecvars.h
  775. + * though used by ldd
  776. + *
  777. * These environment variables are defined by glibc but ignored in
  778. * uClibc, but may very well have an equivalent in uClibc.
  779. *
  780. - * MALLOC_TRACE, RESOLV_HOST_CONF, TZDIR, GCONV_PATH, LD_USE_LOAD_BIAS,
  781. - * LD_PROFILE, LD_ORIGIN_PATH, LOCPATH, NLSPATH
  782. + * LD_ORIGIN_PATH, LD_PROFILE, LD_USE_LOAD_BIAS, LD_DYNAMIC_WEAK, LD_SHOW_AUXV,
  783. + * GCONV_PATH, GETCONF_DIR, HOSTALIASES, LOCALDOMAIN, LOCPATH, MALLOC_TRACE,
  784. + * NLSPATH, RESOLV_HOST_CONF, RES_OPTIONS, TZDIR
  785. */
  786. diff -urN uClibc-0.9.28.orig/ldso/ldso/Makefile uClibc-0.9.28/ldso/ldso/Makefile
  787. --- uClibc-0.9.28.orig/ldso/ldso/Makefile 2006-05-02 10:47:27.000000000 -0600
  788. +++ uClibc-0.9.28/ldso/ldso/Makefile 2006-04-28 00:14:35.000000000 -0600
  789. @@ -42,7 +42,9 @@
  790. endif
  791. XXFLAGS+= -DUCLIBC_LDSO=\"$(UCLIBC_LDSO)\" $(XARCH_CFLAGS) $(CPU_CFLAGS) $(PICFLAG) \
  792. -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
  793. - -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I. -I$(TOPDIR)include
  794. + -fno-builtin -nostdinc -D_LIBC \
  795. + -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" \
  796. + -I$(TOPDIR)ldso/ldso/$(TARGET_ARCH) -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I$(TOPDIR)include
  797. # BEWARE!!! At least mips* will die if -O0 is used!!!
  798. XXFLAGS:=$(XXFLAGS:-O0=-O1)
  799. diff -urN uClibc-0.9.28.orig/ldso/ldso/arm/dl-startup.h uClibc-0.9.28/ldso/ldso/arm/dl-startup.h
  800. --- uClibc-0.9.28.orig/ldso/ldso/arm/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  801. +++ uClibc-0.9.28/ldso/ldso/arm/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  802. @@ -1,10 +1,15 @@
  803. /* vi: set sw=4 ts=4: */
  804. /*
  805. * Architecture specific code used by dl-startup.c
  806. - * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  807. + * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  808. + *
  809. + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  810. */
  811. -asm(
  812. +#include <features.h>
  813. +
  814. +#if !defined(__thumb__)
  815. +__asm__(
  816. " .text\n"
  817. " .globl _start\n"
  818. " .type _start,%function\n"
  819. @@ -40,7 +45,78 @@
  820. " ldr r0, .L_FINI_PROC\n"
  821. " ldr r0, [sl, r0]\n"
  822. " @ jump to the user_s entry point\n"
  823. +#if defined(__USE_BX__)
  824. + " bx r6\n"
  825. +#else
  826. + " mov pc, r6\n"
  827. +#endif
  828. + ".L_GET_GOT:\n"
  829. + " .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n"
  830. + ".L_SKIP_ARGS:\n"
  831. + " .word _dl_skip_args(GOTOFF)\n"
  832. + ".L_FINI_PROC:\n"
  833. + " .word _dl_fini(GOT)\n"
  834. + "\n\n"
  835. + " .size _start,.-_start\n"
  836. + ".previous\n"
  837. +);
  838. +#else
  839. +__asm__(
  840. + " .text\n"
  841. + " .arm\n"
  842. + " .globl _start\n"
  843. + " .type _start,%function\n"
  844. + "_start:\n"
  845. + " @ dumb: can't persuade the linker to make the start address\n"
  846. + " @ odd, so use an arm function and change to thumb (_dl_start\n"
  847. + " @ is thumb)\n"
  848. + " adr r0, __dl_thumb_start+1\n"
  849. + " bx r0\n"
  850. + "\n\n"
  851. + " .thumb\n"
  852. + " .globl __dl_thumb_start\n"
  853. + " .thumb_func\n"
  854. + " .type __dl_thumb_start,%function\n"
  855. + "__dl_thumb_start:\n"
  856. + " @ at start time, all the args are on the stack\n"
  857. + " mov r0, sp\n"
  858. + " bl _dl_start\n"
  859. + " @ returns user entry point in r0\n"
  860. + " mov r6, r0\n"
  861. + " @ we are PIC code, so get global offset table\n"
  862. + " ldr r7, .L_GET_GOT\n"
  863. + ".L_GOT_GOT:\n"
  864. + " add r7, pc\n"
  865. + " @ See if we were run as a command with the executable file\n"
  866. + " @ name as an extra leading argument.\n"
  867. + " ldr r4, .L_SKIP_ARGS\n"
  868. + " ldr r4, [r7, r4]\n"
  869. + " @ get the original arg count\n"
  870. + " ldr r1, [sp]\n"
  871. + " @ subtract _dl_skip_args from it\n"
  872. + " sub r1, r1, r4\n"
  873. + " @ adjust the stack pointer to skip them\n"
  874. + " lsl r4, r4, #2\n"
  875. + " add sp, r4\n"
  876. + " @ get the argv address\n"
  877. + " add r2, sp, #4\n"
  878. + " @ store the new argc in the new stack location\n"
  879. + " str r1, [sp]\n"
  880. + " @ compute envp\n"
  881. + " lsl r3, r1, #2\n"
  882. + " add r3, r3, r2\n"
  883. + " add r3, #4\n"
  884. + "\n\n"
  885. + " @ load the finalizer function\n"
  886. + " ldr r0, .L_FINI_PROC\n"
  887. + " ldr r0, [r7, r0]\n"
  888. + " @ jump to the user_s entry point\n"
  889. +#if defined(__USE_BX__)
  890. + " bx r6\n"
  891. +#else
  892. " mov pc, r6\n"
  893. +#endif
  894. + "\n\n"
  895. ".L_GET_GOT:\n"
  896. " .word _GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4\n"
  897. ".L_SKIP_ARGS:\n"
  898. @@ -51,6 +127,7 @@
  899. " .size _start,.-_start\n"
  900. ".previous\n"
  901. );
  902. +#endif
  903. /* Get a pointer to the argv array. On many platforms this can be just
  904. @@ -115,9 +192,3 @@
  905. _dl_exit(1);
  906. }
  907. }
  908. -
  909. -
  910. -/* Transfer control to the user's application, once the dynamic loader is
  911. - * done. This routine has to exit the current function, then call the
  912. - * _dl_elf_main function. */
  913. -#define START() return _dl_elf_main;
  914. diff -urN uClibc-0.9.28.orig/ldso/ldso/arm/dl-syscalls.h uClibc-0.9.28/ldso/ldso/arm/dl-syscalls.h
  915. --- uClibc-0.9.28.orig/ldso/ldso/arm/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  916. +++ uClibc-0.9.28/ldso/ldso/arm/dl-syscalls.h 2006-04-28 00:14:35.000000000 -0600
  917. @@ -1,6 +1,7 @@
  918. /* We can't use the real errno in ldso, since it has not yet
  919. * been dynamicly linked in yet. */
  920. +#include "sys/syscall.h"
  921. extern int _dl_errno;
  922. +#undef __set_errno
  923. #define __set_errno(X) {(_dl_errno) = (X);}
  924. -#include "sys/syscall.h"
  925. diff -urN uClibc-0.9.28.orig/ldso/ldso/arm/dl-sysdep.h uClibc-0.9.28/ldso/ldso/arm/dl-sysdep.h
  926. --- uClibc-0.9.28.orig/ldso/ldso/arm/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  927. +++ uClibc-0.9.28/ldso/ldso/arm/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  928. @@ -43,6 +43,7 @@
  929. return m;
  930. }
  931. #define do_rem(result, n, base) ((result) = arm_modulus(n, base))
  932. +#define do_div_10(result, remain) ((result) = (((result) - (remain)) / 2) * -(-1ul / 5ul))
  933. /* Here we define the magic numbers that this dynamic loader should accept */
  934. #define MAGIC1 EM_ARM
  935. @@ -85,7 +86,25 @@
  936. extern void __dl_start asm ("_dl_start");
  937. Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
  938. Elf32_Addr pcrel_addr;
  939. +#if !defined __thumb__
  940. asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
  941. +#else
  942. + int tmp;
  943. + /* The above adr will not work on thumb because it
  944. + * is negative. The only safe way is to temporarily
  945. + * swap to arm.
  946. + */
  947. + asm( ".align 2\n"
  948. + " bx pc\n"
  949. + " nop \n"
  950. + " .arm \n"
  951. + " adr %0, _dl_start\n"
  952. + " .align 2\n"
  953. + " orr %1, pc, #1\n"
  954. + " bx %1\n"
  955. + " .force_thumb\n"
  956. + : "=r" (pcrel_addr), "=&r" (tmp));
  957. +#endif
  958. return pcrel_addr - got_addr;
  959. }
  960. diff -urN uClibc-0.9.28.orig/ldso/ldso/arm/elfinterp.c uClibc-0.9.28/ldso/ldso/arm/elfinterp.c
  961. --- uClibc-0.9.28.orig/ldso/ldso/arm/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  962. +++ uClibc-0.9.28/ldso/ldso/arm/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  963. @@ -38,6 +38,8 @@
  964. a more than adequate job of explaining everything required to get this
  965. working. */
  966. +#include "ldso.h"
  967. +
  968. extern int _dl_linux_resolve(void);
  969. unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
  970. @@ -63,7 +65,6 @@
  971. strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
  972. symname = strtab + symtab[symtab_index].st_name;
  973. -
  974. if (unlikely(reloc_type != R_ARM_JUMP_SLOT)) {
  975. _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
  976. _dl_progname);
  977. diff -urN uClibc-0.9.28.orig/ldso/ldso/cris/dl-startup.h uClibc-0.9.28/ldso/ldso/cris/dl-startup.h
  978. --- uClibc-0.9.28.orig/ldso/ldso/cris/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  979. +++ uClibc-0.9.28/ldso/ldso/cris/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  980. @@ -4,22 +4,43 @@
  981. /* This code fixes the stack pointer so that the dynamic linker
  982. * can find argc, argv and auxvt (Auxillary Vector Table). */
  983. +#ifdef __arch_v32
  984. +
  985. +asm("" \
  986. +" .text\n" \
  987. +" .globl _start\n" \
  988. +" .type _start,@function\n" \
  989. +"_start:\n" \
  990. +" move.d $sp,$r10\n" \
  991. +" lapc _dl_start,$r9\n" \
  992. +" jsr $r9\n" \
  993. +" nop\n" \
  994. +" moveq 0,$r8\n" \
  995. +" jump $r10\n" \
  996. +" move $r8,$srp\n" \
  997. +" .size _start,.-_start\n" \
  998. +" .previous\n" \
  999. +);
  1000. +
  1001. +#else
  1002. +
  1003. asm("" \
  1004. " .text\n" \
  1005. " .globl _start\n" \
  1006. " .type _start,@function\n" \
  1007. "_start:\n" \
  1008. -" move.d $sp,$r10\n" \
  1009. -" move.d $pc,$r9\n" \
  1010. -" add.d _dl_start - ., $r9\n" \
  1011. -" jsr $r9\n" \
  1012. -" moveq 0,$r8\n" \
  1013. -" move $r8,$srp\n" \
  1014. -" jump $r10\n" \
  1015. +" move.d $sp,$r10\n" \
  1016. +" move.d $pc,$r9\n" \
  1017. +" add.d _dl_start - ., $r9\n" \
  1018. +" jsr $r9\n" \
  1019. +" moveq 0,$r8\n" \
  1020. +" move $r8,$srp\n" \
  1021. +" jump $r10\n" \
  1022. " .size _start,.-_start\n" \
  1023. " .previous\n" \
  1024. );
  1025. +#endif /* __arch_v32 */
  1026. /* Get a pointer to the argv array. On many platforms this can be just
  1027. * the address if the first argument, on other platforms we need to
  1028. @@ -58,8 +79,3 @@
  1029. break;
  1030. }
  1031. }
  1032. -
  1033. -/* Transfer control to the user's application, once the dynamic loader is
  1034. - * done. This routine has to exit the current function, then call the
  1035. - * _dl_elf_main function. */
  1036. -#define START() return _dl_elf_main
  1037. diff -urN uClibc-0.9.28.orig/ldso/ldso/cris/dl-syscalls.h uClibc-0.9.28/ldso/ldso/cris/dl-syscalls.h
  1038. --- uClibc-0.9.28.orig/ldso/ldso/cris/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  1039. +++ uClibc-0.9.28/ldso/ldso/cris/dl-syscalls.h 2006-04-28 00:14:35.000000000 -0600
  1040. @@ -1,5 +1,6 @@
  1041. /* We can't use the real errno in ldso, since it has not yet
  1042. * been dynamicly linked in yet. */
  1043. +#include "sys/syscall.h"
  1044. extern int _dl_errno;
  1045. +#undef __set_errno
  1046. #define __set_errno(X) {(_dl_errno) = (X);}
  1047. -#include "sys/syscall.h"
  1048. diff -urN uClibc-0.9.28.orig/ldso/ldso/cris/dl-sysdep.h uClibc-0.9.28/ldso/ldso/cris/dl-sysdep.h
  1049. --- uClibc-0.9.28.orig/ldso/ldso/cris/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  1050. +++ uClibc-0.9.28/ldso/ldso/cris/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  1051. @@ -18,8 +18,6 @@
  1052. struct elf_resolve;
  1053. extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
  1054. -#define do_rem(result, n, base) ((result) = (n) % (base))
  1055. -
  1056. /* 8192 bytes alignment */
  1057. #define PAGE_ALIGN 0xffffe000
  1058. #define ADDR_ALIGN 0x1fff
  1059. @@ -68,8 +66,32 @@
  1060. {
  1061. Elf32_Addr gotaddr_diff;
  1062. +#ifdef __arch_v32
  1063. + extern char ___CRISv32_dummy[] __asm__ ("_dl_start");
  1064. +
  1065. + __asm__ ("addo.w _dl_start:GOT16,$r0,$acr\n\t"
  1066. + "lapc _dl_start,%0\n\t"
  1067. + "sub.d [$acr],%0"
  1068. + /* For v32, we need to force GCC to have R0 loaded with
  1069. + _GLOBAL_OFFSET_TABLE_ at this point, which might not
  1070. + otherwise have happened in the caller. (For v10, it's
  1071. + loaded for non-global variables too, so we don't need
  1072. + anything special there.) We accomplish this by faking the
  1073. + address of a global variable (as seen by GCC) as input to
  1074. + the asm; that address calculation goes through the GOT.
  1075. + Use of this function happens before we've filled in the
  1076. + GOT, so the address itself will not be correctly
  1077. + calculated, therefore we don't use any symbol whose
  1078. + address may be re-used later on. Let's just reuse the
  1079. + _dl_start symbol, faking it as a global by renaming it as
  1080. + another variable through an asm. */
  1081. + : "=r" (gotaddr_diff)
  1082. + : "g" (___CRISv32_dummy)
  1083. + : "acr");
  1084. +#else
  1085. __asm__ ("sub.d [$r0+_dl_start:GOT16],$r0,%0\n\t"
  1086. "add.d _dl_start:GOTOFF,%0" : "=r" (gotaddr_diff));
  1087. +#endif
  1088. return gotaddr_diff;
  1089. }
  1090. diff -urN uClibc-0.9.28.orig/ldso/ldso/cris/resolve.S uClibc-0.9.28/ldso/ldso/cris/resolve.S
  1091. --- uClibc-0.9.28.orig/ldso/ldso/cris/resolve.S 2006-05-02 10:47:27.000000000 -0600
  1092. +++ uClibc-0.9.28/ldso/ldso/cris/resolve.S 2006-04-28 00:14:35.000000000 -0600
  1093. @@ -17,33 +17,73 @@
  1094. .globl _dl_linux_resolve
  1095. .type _dl_linux_resolve,@function
  1096. +#ifdef __arch_v32
  1097. +
  1098. +_dl_linux_resolve:
  1099. + subq 4,$sp
  1100. + move.d $r0,[$sp]
  1101. + subq 4,$sp
  1102. + move.d $r13,[$sp]
  1103. + subq 4,$sp
  1104. + move.d $r12,[$sp]
  1105. + subq 4,$sp
  1106. + move.d $r11,[$sp]
  1107. + subq 4,$sp
  1108. + addoq 5*4,$sp,$acr
  1109. + move.d $r10,[$sp]
  1110. + subq 4,$sp
  1111. + move $mof,$r10
  1112. + move.d $r9,[$sp]
  1113. + subq 4,$sp
  1114. + move.d [$acr],$r11
  1115. + move $srp,[$sp]
  1116. + lapc _GLOBAL_OFFSET_TABLE_,$r0
  1117. + move.d _dl_linux_resolver:PLTG,$r9
  1118. + add.d $r0,$r9
  1119. + jsr $r9
  1120. + nop
  1121. + move.d $r10,$acr
  1122. + move [$sp+],$srp
  1123. + move.d [$sp+],$r9
  1124. + move.d [$sp+],$r10
  1125. + move.d [$sp+],$r11
  1126. + move.d [$sp+],$r12
  1127. + move.d [$sp+],$r13
  1128. + move.d [$sp+],$r0
  1129. + jump $acr
  1130. + addq 4,$sp
  1131. +
  1132. +#else
  1133. +
  1134. _dl_linux_resolve:
  1135. - push $r13
  1136. - push $r12
  1137. - push $r11
  1138. - push $r10
  1139. - push $r9
  1140. - push $r0
  1141. - push $srp
  1142. - move.d [$sp+7*4],$r11
  1143. - move $mof,$r10
  1144. + push $r13
  1145. + push $r12
  1146. + push $r11
  1147. + push $r10
  1148. + push $r9
  1149. + push $r0
  1150. + push $srp
  1151. + move.d [$sp+7*4],$r11
  1152. + move $mof,$r10
  1153. #ifdef __PIC__
  1154. - move.d $pc,$r0
  1155. - sub.d .:GOTOFF,$r0
  1156. - move.d _dl_linux_resolver:PLTG,$r9
  1157. - add.d $r0,$r9
  1158. - jsr $r9
  1159. + move.d $pc,$r0
  1160. + sub.d .:GOTOFF,$r0
  1161. + move.d _dl_linux_resolver:PLTG,$r9
  1162. + add.d $r0,$r9
  1163. + jsr $r9
  1164. #else
  1165. - jsr _dl_linux_resolver
  1166. + jsr _dl_linux_resolver
  1167. #endif
  1168. - move.d $r10,[$sp+7*4]
  1169. - pop $srp
  1170. - pop $r0
  1171. - pop $r9
  1172. - pop $r10
  1173. - pop $r11
  1174. - pop $r12
  1175. - pop $r13
  1176. - jump [$sp+]
  1177. + move.d $r10,[$sp+7*4]
  1178. + pop $srp
  1179. + pop $r0
  1180. + pop $r9
  1181. + pop $r10
  1182. + pop $r11
  1183. + pop $r12
  1184. + pop $r13
  1185. + jump [$sp+]
  1186. +
  1187. +#endif /* __arch_v32 */
  1188. .size _dl_linux_resolve, . - _dl_linux_resolve
  1189. diff -urN uClibc-0.9.28.orig/ldso/ldso/dl-elf.c uClibc-0.9.28/ldso/ldso/dl-elf.c
  1190. --- uClibc-0.9.28.orig/ldso/ldso/dl-elf.c 2006-05-02 10:47:27.000000000 -0600
  1191. +++ uClibc-0.9.28/ldso/ldso/dl-elf.c 2006-05-02 13:50:58.000000000 -0600
  1192. @@ -3,7 +3,7 @@
  1193. * This file contains the helper routines to load an ELF shared
  1194. * library into memory and add the symbol table info to the chain.
  1195. *
  1196. - * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  1197. + * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
  1198. * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
  1199. * David Engel, Hongjiu Lu and Mitch D'Souza
  1200. *
  1201. @@ -60,8 +60,8 @@
  1202. _dl_cache_addr = (caddr_t) _dl_mmap(0, _dl_cache_size, PROT_READ, MAP_SHARED, fd, 0);
  1203. _dl_close(fd);
  1204. if (_dl_mmap_check_error(_dl_cache_addr)) {
  1205. - _dl_dprintf(2, "%s: can't map cache '%s'\n",
  1206. - _dl_progname, LDSO_CACHE);
  1207. + _dl_dprintf(2, "%s:%i: can't map '%s'\n",
  1208. + _dl_progname, __LINE__, LDSO_CACHE);
  1209. return -1;
  1210. }
  1211. @@ -115,7 +115,7 @@
  1212. #endif
  1213. -void
  1214. +void
  1215. _dl_protect_relro (struct elf_resolve *l)
  1216. {
  1217. ElfW(Addr) start = ((l->loadaddr + l->relro_addr)
  1218. @@ -136,27 +136,41 @@
  1219. search_for_named_library(const char *name, int secure, const char *path_list,
  1220. struct dyn_elf **rpnt)
  1221. {
  1222. - char *path, *path_n;
  1223. - char mylibname[2050];
  1224. + char *path, *path_n, *mylibname;
  1225. struct elf_resolve *tpnt;
  1226. - int done = 0;
  1227. + int done;
  1228. if (path_list==NULL)
  1229. return NULL;
  1230. - /* We need a writable copy of this string */
  1231. - path = _dl_strdup(path_list);
  1232. - if (!path) {
  1233. + /* We need a writable copy of this string, but we don't
  1234. + * need this allocated permanently since we don't want
  1235. + * to leak memory, so use alloca to put path on the stack */
  1236. + done = _dl_strlen(path_list);
  1237. + path = alloca(done + 1);
  1238. +
  1239. + /* another bit of local storage */
  1240. + mylibname = alloca(2050);
  1241. +
  1242. + /* gcc inlines alloca using a single instruction adjusting
  1243. + * the stack pointer and no stack overflow check and thus
  1244. + * no NULL error return. No point leaving in dead code... */
  1245. +#if 0
  1246. + if (!path || !mylibname) {
  1247. _dl_dprintf(2, "Out of memory!\n");
  1248. _dl_exit(0);
  1249. }
  1250. +#endif
  1251. +
  1252. + _dl_memcpy(path, path_list, done+1);
  1253. /* Unlike ldd.c, don't bother to eliminate double //s */
  1254. /* Replace colons with zeros in path_list */
  1255. /* : at the beginning or end of path maps to CWD */
  1256. /* :: anywhere maps CWD */
  1257. - /* "" maps to CWD */
  1258. + /* "" maps to CWD */
  1259. + done = 0;
  1260. path_n = path;
  1261. do {
  1262. if (*path == 0) {
  1263. @@ -180,71 +194,6 @@
  1264. return NULL;
  1265. }
  1266. -/* Check if the named library is already loaded... */
  1267. -struct elf_resolve *_dl_check_if_named_library_is_loaded(const char *full_libname,
  1268. - int trace_loaded_objects)
  1269. -{
  1270. - const char *pnt, *pnt1;
  1271. - struct elf_resolve *tpnt1;
  1272. - const char *libname, *libname2;
  1273. - static const char libc[] = "libc.so.";
  1274. - static const char aborted_wrong_lib[] = "%s: aborted attempt to load %s!\n";
  1275. -
  1276. - pnt = libname = full_libname;
  1277. -
  1278. - _dl_if_debug_dprint("Checking if '%s' is already loaded\n", full_libname);
  1279. - /* quick hack to ensure mylibname buffer doesn't overflow. don't
  1280. - allow full_libname or any directory to be longer than 1024. */
  1281. - if (_dl_strlen(full_libname) > 1024)
  1282. - return NULL;
  1283. -
  1284. - /* Skip over any initial initial './' and '/' stuff to
  1285. - * get the short form libname with no path garbage */
  1286. - pnt1 = _dl_strrchr(pnt, '/');
  1287. - if (pnt1) {
  1288. - libname = pnt1 + 1;
  1289. - }
  1290. -
  1291. - /* Make sure they are not trying to load the wrong C library!
  1292. - * This sometimes happens esp with shared libraries when the
  1293. - * library path is somehow wrong! */
  1294. -#define isdigit(c) (c >= '0' && c <= '9')
  1295. - if ((_dl_strncmp(libname, libc, 8) == 0) && _dl_strlen(libname) >=8 &&
  1296. - isdigit(libname[8]))
  1297. - {
  1298. - /* Abort attempts to load glibc, libc5, etc */
  1299. - if ( libname[8]!='0') {
  1300. - if (!trace_loaded_objects) {
  1301. - _dl_dprintf(2, aborted_wrong_lib, libname, _dl_progname);
  1302. - _dl_exit(1);
  1303. - }
  1304. - return NULL;
  1305. - }
  1306. - }
  1307. -
  1308. - /* Critical step! Weed out duplicates early to avoid
  1309. - * function aliasing, which wastes memory, and causes
  1310. - * really bad things to happen with weaks and globals. */
  1311. - for (tpnt1 = _dl_loaded_modules; tpnt1; tpnt1 = tpnt1->next) {
  1312. -
  1313. - /* Skip over any initial initial './' and '/' stuff to
  1314. - * get the short form libname with no path garbage */
  1315. - libname2 = tpnt1->libname;
  1316. - pnt1 = _dl_strrchr(libname2, '/');
  1317. - if (pnt1) {
  1318. - libname2 = pnt1 + 1;
  1319. - }
  1320. -
  1321. - if (_dl_strcmp(libname2, libname) == 0) {
  1322. - /* Well, that was certainly easy */
  1323. - return tpnt1;
  1324. - }
  1325. - }
  1326. -
  1327. - return NULL;
  1328. -}
  1329. -
  1330. -
  1331. /* Used to return error codes back to dlopen et. al. */
  1332. unsigned long _dl_error_number;
  1333. unsigned long _dl_internal_error_number;
  1334. @@ -271,14 +220,6 @@
  1335. libname = pnt + 1;
  1336. }
  1337. - /* Critical step! Weed out duplicates early to avoid
  1338. - * function aliasing, which wastes memory, and causes
  1339. - * really bad things to happen with weaks and globals. */
  1340. - if ((tpnt1=_dl_check_if_named_library_is_loaded(libname, trace_loaded_objects))!=NULL) {
  1341. - tpnt1->usage_count++;
  1342. - return tpnt1;
  1343. - }
  1344. -
  1345. _dl_if_debug_dprint("\tfind library='%s'; searching\n", libname);
  1346. /* If the filename has any '/', try it straight and leave it at that.
  1347. For IBCS2 compatibility under linux, we substitute the string
  1348. @@ -290,7 +231,6 @@
  1349. if (tpnt1) {
  1350. return tpnt1;
  1351. }
  1352. - //goto goof;
  1353. }
  1354. /*
  1355. @@ -411,56 +351,45 @@
  1356. int i, flags, piclib, infile;
  1357. ElfW(Addr) relro_addr = 0;
  1358. size_t relro_size = 0;
  1359. -
  1360. - /* If this file is already loaded, skip this step */
  1361. - tpnt = _dl_check_hashed_files(libname);
  1362. - if (tpnt) {
  1363. - if (*rpnt) {
  1364. - (*rpnt)->next = (struct dyn_elf *) _dl_malloc(sizeof(struct dyn_elf));
  1365. - _dl_memset((*rpnt)->next, 0, sizeof(struct dyn_elf));
  1366. - (*rpnt)->next->prev = (*rpnt);
  1367. - *rpnt = (*rpnt)->next;
  1368. - (*rpnt)->dyn = tpnt;
  1369. - tpnt->symbol_scope = _dl_symbol_tables;
  1370. - }
  1371. - tpnt->usage_count++;
  1372. - tpnt->libtype = elf_lib;
  1373. - _dl_if_debug_dprint("file='%s'; already loaded\n", libname);
  1374. - return tpnt;
  1375. - }
  1376. -
  1377. - /* If we are in secure mode (i.e. a setu/gid binary using LD_PRELOAD),
  1378. - we don't load the library if it isn't setuid. */
  1379. -
  1380. - if (secure) {
  1381. - struct stat st;
  1382. -
  1383. - if (_dl_stat(libname, &st) || !(st.st_mode & S_ISUID))
  1384. - return NULL;
  1385. - }
  1386. + struct stat st;
  1387. libaddr = 0;
  1388. infile = _dl_open(libname, O_RDONLY, 0);
  1389. if (infile < 0) {
  1390. -#if 0
  1391. - /*
  1392. - * NO! When we open shared libraries we may search several paths.
  1393. - * it is inappropriate to generate an error here.
  1394. - */
  1395. - _dl_dprintf(2, "%s: can't open '%s'\n", _dl_progname, libname);
  1396. -#endif
  1397. _dl_internal_error_number = LD_ERROR_NOFILE;
  1398. return NULL;
  1399. }
  1400. + if (_dl_fstat(infile, &st) < 0) {
  1401. + _dl_internal_error_number = LD_ERROR_NOFILE;
  1402. + _dl_close(infile);
  1403. + return NULL;
  1404. + }
  1405. + /* If we are in secure mode (i.e. a setu/gid binary using LD_PRELOAD),
  1406. + we don't load the library if it isn't setuid. */
  1407. + if (secure)
  1408. + if (!(st.st_mode & S_ISUID)) {
  1409. + _dl_close(infile);
  1410. + return NULL;
  1411. + }
  1412. +
  1413. + /* Check if file is already loaded */
  1414. + for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
  1415. + if(tpnt->st_dev == st.st_dev && tpnt->st_ino == st.st_ino) {
  1416. + /* Already loaded */
  1417. + tpnt->usage_count++;
  1418. + _dl_close(infile);
  1419. + return tpnt;
  1420. + }
  1421. + }
  1422. header = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
  1423. MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  1424. if (_dl_mmap_check_error(header)) {
  1425. - _dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
  1426. + _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
  1427. _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
  1428. _dl_close(infile);
  1429. return NULL;
  1430. - };
  1431. + }
  1432. _dl_read(infile, header, _dl_pagesize);
  1433. epnt = (ElfW(Ehdr) *) (intptr_t) header;
  1434. @@ -475,7 +404,7 @@
  1435. _dl_close(infile);
  1436. _dl_munmap(header, _dl_pagesize);
  1437. return NULL;
  1438. - };
  1439. + }
  1440. if ((epnt->e_type != ET_DYN) || (epnt->e_machine != MAGIC1
  1441. #ifdef MAGIC2
  1442. @@ -490,7 +419,7 @@
  1443. _dl_close(infile);
  1444. _dl_munmap(header, _dl_pagesize);
  1445. return NULL;
  1446. - };
  1447. + }
  1448. ppnt = (ElfW(Phdr) *)(intptr_t) & header[epnt->e_phoff];
  1449. @@ -502,7 +431,7 @@
  1450. _dl_dprintf(2, "%s: '%s' has more than one dynamic section\n",
  1451. _dl_progname, libname);
  1452. dynamic_addr = ppnt->p_vaddr;
  1453. - };
  1454. + }
  1455. if (ppnt->p_type == PT_LOAD) {
  1456. /* See if this is a PIC library. */
  1457. @@ -518,7 +447,7 @@
  1458. }
  1459. }
  1460. ppnt++;
  1461. - };
  1462. + }
  1463. maxvma = (maxvma + ADDR_ALIGN) & ~ADDR_ALIGN;
  1464. minvma = minvma & ~0xffffU;
  1465. @@ -530,12 +459,12 @@
  1466. status = (char *) _dl_mmap((char *) (piclib ? 0 : minvma),
  1467. maxvma - minvma, PROT_NONE, flags | MAP_ANONYMOUS, -1, 0);
  1468. if (_dl_mmap_check_error(status)) {
  1469. - _dl_dprintf(2, "%s: can't map %s\n", _dl_progname, libname);
  1470. + _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
  1471. _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
  1472. _dl_close(infile);
  1473. _dl_munmap(header, _dl_pagesize);
  1474. return NULL;
  1475. - };
  1476. + }
  1477. libaddr = (unsigned long) status;
  1478. flags |= MAP_FIXED;
  1479. @@ -567,14 +496,14 @@
  1480. ppnt->p_offset & OFFS_ALIGN);
  1481. if (_dl_mmap_check_error(status)) {
  1482. - _dl_dprintf(2, "%s: can't map '%s'\n",
  1483. - _dl_progname, libname);
  1484. + _dl_dprintf(2, "%s:%i: can't map '%s'\n",
  1485. + _dl_progname, __LINE__, libname);
  1486. _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
  1487. _dl_munmap((char *) libaddr, maxvma - minvma);
  1488. _dl_close(infile);
  1489. _dl_munmap(header, _dl_pagesize);
  1490. return NULL;
  1491. - };
  1492. + }
  1493. /* Pad the last page with zeroes. */
  1494. cpnt = (char *) (status + (ppnt->p_vaddr & ADDR_ALIGN) +
  1495. @@ -601,21 +530,21 @@
  1496. ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags,
  1497. infile, ppnt->p_offset & OFFS_ALIGN);
  1498. if (_dl_mmap_check_error(status)) {
  1499. - _dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
  1500. + _dl_dprintf(2, "%s:%i: can't map '%s'\n", _dl_progname, __LINE__, libname);
  1501. _dl_internal_error_number = LD_ERROR_MMAP_FAILED;
  1502. _dl_munmap((char *) libaddr, maxvma - minvma);
  1503. _dl_close(infile);
  1504. _dl_munmap(header, _dl_pagesize);
  1505. return NULL;
  1506. - };
  1507. + }
  1508. /* if(libaddr == 0 && piclib) {
  1509. libaddr = (unsigned long) status;
  1510. flags |= MAP_FIXED;
  1511. - }; */
  1512. - };
  1513. + } */
  1514. + }
  1515. ppnt++;
  1516. - };
  1517. + }
  1518. _dl_close(infile);
  1519. /* For a non-PIC library, the addresses are all absolute */
  1520. @@ -665,6 +594,8 @@
  1521. dynamic_addr, 0);
  1522. tpnt->relro_addr = relro_addr;
  1523. tpnt->relro_size = relro_size;
  1524. + tpnt->st_dev = st.st_dev;
  1525. + tpnt->st_ino = st.st_ino;
  1526. tpnt->ppnt = (ElfW(Phdr) *)(intptr_t) (tpnt->loadaddr + epnt->e_phoff);
  1527. tpnt->n_phent = epnt->e_phnum;
  1528. @@ -693,7 +624,7 @@
  1529. if (lpnt) {
  1530. lpnt = (unsigned long *) (dynamic_info[DT_PLTGOT]);
  1531. INIT_GOT(lpnt, tpnt);
  1532. - };
  1533. + }
  1534. _dl_if_debug_dprint("\n\tfile='%s'; generating link map\n", libname);
  1535. _dl_if_debug_dprint("\t\tdynamic: %x base: %x\n", dynamic_addr, libaddr);
  1536. @@ -714,10 +645,12 @@
  1537. ElfW(Addr) reloc_addr;
  1538. if (rpnt->next)
  1539. - goof += _dl_fixup(rpnt->next, now_flag);
  1540. + goof = _dl_fixup(rpnt->next, now_flag);
  1541. + if (goof)
  1542. + return goof;
  1543. tpnt = rpnt->dyn;
  1544. - if(!(tpnt->init_flag & RELOCS_DONE))
  1545. + if(!(tpnt->init_flag & RELOCS_DONE))
  1546. _dl_if_debug_dprint("relocation processing: %s\n", tpnt->libname);
  1547. if (unlikely(tpnt->dynamic_info[UNSUPPORTED_RELOC_TYPE])) {
  1548. @@ -735,7 +668,6 @@
  1549. #endif
  1550. if (tpnt->dynamic_info[DT_RELOC_TABLE_ADDR] &&
  1551. !(tpnt->init_flag & RELOCS_DONE)) {
  1552. - tpnt->init_flag |= RELOCS_DONE;
  1553. reloc_addr = tpnt->dynamic_info[DT_RELOC_TABLE_ADDR];
  1554. relative_count = tpnt->dynamic_info[DT_RELCONT_IDX];
  1555. if (relative_count) { /* Optimize the XX_RELATIVE relocations if possible */
  1556. @@ -746,14 +678,14 @@
  1557. goof += _dl_parse_relocation_information(rpnt,
  1558. reloc_addr,
  1559. reloc_size);
  1560. + tpnt->init_flag |= RELOCS_DONE;
  1561. }
  1562. if (tpnt->dynamic_info[DT_BIND_NOW])
  1563. now_flag = RTLD_NOW;
  1564. if (tpnt->dynamic_info[DT_JMPREL] &&
  1565. (!(tpnt->init_flag & JMP_RELOCS_DONE) ||
  1566. (now_flag && !(tpnt->rtld_flags & now_flag)))) {
  1567. - tpnt->rtld_flags |= now_flag;
  1568. - tpnt->init_flag |= JMP_RELOCS_DONE;
  1569. + tpnt->rtld_flags |= now_flag;
  1570. if (!(tpnt->rtld_flags & RTLD_NOW)) {
  1571. _dl_parse_lazy_relocation_information(rpnt,
  1572. tpnt->dynamic_info[DT_JMPREL],
  1573. @@ -763,6 +695,7 @@
  1574. tpnt->dynamic_info[DT_JMPREL],
  1575. tpnt->dynamic_info[DT_PLTRELSZ]);
  1576. }
  1577. + tpnt->init_flag |= JMP_RELOCS_DONE;
  1578. }
  1579. return goof;
  1580. }
  1581. @@ -770,11 +703,18 @@
  1582. /* Minimal printf which handles only %s, %d, and %x */
  1583. void _dl_dprintf(int fd, const char *fmt, ...)
  1584. {
  1585. - long num;
  1586. +#if __WORDSIZE > 32
  1587. + long int num;
  1588. +#else
  1589. + int num;
  1590. +#endif
  1591. va_list args;
  1592. char *start, *ptr, *string;
  1593. static char *buf;
  1594. + if (!fmt)
  1595. + return;
  1596. +
  1597. buf = _dl_mmap((void *) 0, _dl_pagesize, PROT_READ | PROT_WRITE,
  1598. MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  1599. if (_dl_mmap_check_error(buf)) {
  1600. @@ -784,9 +724,6 @@
  1601. start = ptr = buf;
  1602. - if (!fmt)
  1603. - return;
  1604. -
  1605. if (_dl_strlen(fmt) >= (_dl_pagesize - 1)) {
  1606. _dl_write(fd, "overflow\n", 11);
  1607. _dl_exit(20);
  1608. @@ -818,8 +755,11 @@
  1609. case 'd':
  1610. {
  1611. char tmp[22];
  1612. - num = va_arg(args, long);
  1613. -
  1614. +#if __WORDSIZE > 32
  1615. + num = va_arg(args, long int);
  1616. +#else
  1617. + num = va_arg(args, int);
  1618. +#endif
  1619. string = _dl_simple_ltoa(tmp, num);
  1620. _dl_write(fd, string, _dl_strlen(string));
  1621. break;
  1622. @@ -828,8 +768,11 @@
  1623. case 'X':
  1624. {
  1625. char tmp[22];
  1626. - num = va_arg(args, long);
  1627. -
  1628. +#if __WORDSIZE > 32
  1629. + num = va_arg(args, long int);
  1630. +#else
  1631. + num = va_arg(args, int);
  1632. +#endif
  1633. string = _dl_simple_ltoahex(tmp, num);
  1634. _dl_write(fd, string, _dl_strlen(string));
  1635. break;
  1636. @@ -864,8 +807,10 @@
  1637. {
  1638. __dl_parse_dynamic_info(dpnt, dynamic_info, debug_addr, load_off);
  1639. }
  1640. +
  1641. +/* we want this in ldso.so and libdl.a but nowhere else */
  1642. #ifdef __USE_GNU
  1643. -#if ! defined LIBDL || (! defined PIC && ! defined __PIC__)
  1644. +#if ! defined SHARED || (! defined PIC && ! defined __PIC__)
  1645. int
  1646. __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data)
  1647. {
  1648. @@ -884,6 +829,6 @@
  1649. }
  1650. return ret;
  1651. }
  1652. -strong_alias(__dl_iterate_phdr, dl_iterate_phdr);
  1653. +strong_alias(__dl_iterate_phdr, dl_iterate_phdr)
  1654. #endif
  1655. #endif
  1656. diff -urN uClibc-0.9.28.orig/ldso/ldso/dl-hash.c uClibc-0.9.28/ldso/ldso/dl-hash.c
  1657. --- uClibc-0.9.28.orig/ldso/ldso/dl-hash.c 2006-05-02 10:47:27.000000000 -0600
  1658. +++ uClibc-0.9.28/ldso/ldso/dl-hash.c 2006-04-28 00:14:35.000000000 -0600
  1659. @@ -57,7 +57,7 @@
  1660. /* This is the hash function that is used by the ELF linker to generate the
  1661. * hash table that each executable and library is required to have. We need
  1662. * it to decode the hash table. */
  1663. -static inline Elf32_Word _dl_elf_hash(const char *name)
  1664. +static inline Elf_Symndx _dl_elf_hash(const char *name)
  1665. {
  1666. unsigned long hash=0;
  1667. unsigned long tmp;
  1668. @@ -77,21 +77,6 @@
  1669. return hash;
  1670. }
  1671. -/* Check to see if a library has already been added to the hash chain. */
  1672. -struct elf_resolve *_dl_check_hashed_files(const char *libname)
  1673. -{
  1674. - struct elf_resolve *tpnt;
  1675. - int len = _dl_strlen(libname);
  1676. -
  1677. - for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
  1678. - if (_dl_strncmp(tpnt->libname, libname, len) == 0 &&
  1679. - (tpnt->libname[len] == '\0' || tpnt->libname[len] == '.'))
  1680. - return tpnt;
  1681. - }
  1682. -
  1683. - return NULL;
  1684. -}
  1685. -
  1686. /*
  1687. * We call this function when we have just read an ELF library or executable.
  1688. * We add the relevant info to the symbol chain, so that we can resolve all
  1689. @@ -99,9 +84,10 @@
  1690. */
  1691. struct elf_resolve *_dl_add_elf_hash_table(const char *libname,
  1692. char *loadaddr, unsigned long *dynamic_info, unsigned long dynamic_addr,
  1693. + //attribute_unused
  1694. unsigned long dynamic_size)
  1695. {
  1696. - Elf32_Word *hash_addr;
  1697. + Elf_Symndx *hash_addr;
  1698. struct elf_resolve *tpnt;
  1699. int i;
  1700. @@ -125,7 +111,7 @@
  1701. tpnt->libtype = loaded_file;
  1702. if (dynamic_info[DT_HASH] != 0) {
  1703. - hash_addr = (Elf32_Word*)dynamic_info[DT_HASH];
  1704. + hash_addr = (Elf_Symndx*)dynamic_info[DT_HASH];
  1705. tpnt->nbucket = *hash_addr++;
  1706. tpnt->nchain = *hash_addr++;
  1707. tpnt->elf_buckets = hash_addr;
  1708. diff -urN uClibc-0.9.28.orig/ldso/ldso/dl-startup.c uClibc-0.9.28/ldso/ldso/dl-startup.c
  1709. --- uClibc-0.9.28.orig/ldso/ldso/dl-startup.c 2006-05-02 10:47:27.000000000 -0600
  1710. +++ uClibc-0.9.28/ldso/ldso/dl-startup.c 2006-04-28 00:14:35.000000000 -0600
  1711. @@ -98,7 +98,7 @@
  1712. int (*_dl_elf_main) (int, char **, char **);
  1713. static void* __rtld_stack_end; /* Points to argc on stack, e.g *((long *)__rtld_stackend) == argc */
  1714. -strong_alias(__rtld_stack_end, __libc_stack_end); /* Exported version of __rtld_stack_end */
  1715. +strong_alias(__rtld_stack_end, __libc_stack_end) /* Exported version of __rtld_stack_end */
  1716. /* When we enter this piece of code, the program stack looks like this:
  1717. argc argument counter (integer)
  1718. @@ -307,5 +307,11 @@
  1719. SEND_STDERR_DEBUG("transfering control to application @ ");
  1720. _dl_elf_main = (int (*)(int, char **, char **)) auxvt[AT_ENTRY].a_un.a_val;
  1721. SEND_ADDRESS_STDERR_DEBUG(_dl_elf_main, 1);
  1722. +
  1723. +#ifndef START
  1724. + return _dl_elf_main;
  1725. +#else
  1726. +#warning You need to update your arch ldso code
  1727. START();
  1728. +#endif
  1729. }
  1730. diff -urN uClibc-0.9.28.orig/ldso/ldso/frv/dl-syscalls.h uClibc-0.9.28/ldso/ldso/frv/dl-syscalls.h
  1731. --- uClibc-0.9.28.orig/ldso/ldso/frv/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  1732. +++ uClibc-0.9.28/ldso/ldso/frv/dl-syscalls.h 2006-04-28 00:14:35.000000000 -0600
  1733. @@ -20,9 +20,10 @@
  1734. /* We can't use the real errno in ldso, since it has not yet
  1735. * been dynamicly linked in yet. */
  1736. +#include "sys/syscall.h"
  1737. extern int _dl_errno;
  1738. +#undef __set_errno
  1739. #define __set_errno(X) {(_dl_errno) = (X);}
  1740. -#include "sys/syscall.h"
  1741. #include <sys/mman.h>
  1742. /* The code below is extracted from libc/sysdeps/linux/frv/_mmap.c */
  1743. diff -urN uClibc-0.9.28.orig/ldso/ldso/frv/dl-sysdep.h uClibc-0.9.28/ldso/ldso/frv/dl-sysdep.h
  1744. --- uClibc-0.9.28.orig/ldso/ldso/frv/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  1745. +++ uClibc-0.9.28/ldso/ldso/frv/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  1746. @@ -65,8 +65,6 @@
  1747. extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden")));
  1748. -#define do_rem(result, n, base) ((result) = (n) % (base))
  1749. -
  1750. /* 16KiB page alignment. Should perhaps be made dynamic using
  1751. getpagesize(), based on AT_PAGESZ from auxvt? */
  1752. #define PAGE_ALIGN 0xffffc000
  1753. diff -urN uClibc-0.9.28.orig/ldso/ldso/frv/elfinterp.c uClibc-0.9.28/ldso/ldso/frv/elfinterp.c
  1754. --- uClibc-0.9.28.orig/ldso/ldso/frv/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  1755. +++ uClibc-0.9.28/ldso/ldso/frv/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  1756. @@ -24,7 +24,7 @@
  1757. the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
  1758. USA. */
  1759. -#include <sys/cdefs.h> /* __attribute_used__ */
  1760. +#include <features.h>
  1761. /* Program to load an ELF binary on a linux system, and run it.
  1762. References to symbols in sharable libraries can be resolved by either
  1763. @@ -37,7 +37,7 @@
  1764. a more than adequate job of explaining everything required to get this
  1765. working. */
  1766. -struct funcdesc_value volatile *__attribute__((__visibility__("hidden")))
  1767. +struct funcdesc_value volatile attribute_hidden *
  1768. _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
  1769. {
  1770. int reloc_type;
  1771. diff -urN uClibc-0.9.28.orig/ldso/ldso/i386/dl-startup.h uClibc-0.9.28/ldso/ldso/i386/dl-startup.h
  1772. --- uClibc-0.9.28.orig/ldso/ldso/i386/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  1773. +++ uClibc-0.9.28/ldso/ldso/i386/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  1774. @@ -3,7 +3,7 @@
  1775. * Architecture specific code used by dl-startup.c
  1776. * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  1777. */
  1778. -asm(
  1779. +__asm__ (
  1780. " .text\n"
  1781. " .align 16\n"
  1782. " .globl _start\n"
  1783. @@ -41,9 +41,9 @@
  1784. #define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) & ARGS)+1)
  1785. /* Handle relocation of the symbols in the dynamic loader. */
  1786. -static inline
  1787. +static __always_inline
  1788. void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
  1789. - unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
  1790. + unsigned long symbol_addr, unsigned long load_addr, attribute_unused Elf32_Sym *symtab)
  1791. {
  1792. switch (ELF32_R_TYPE(rpnt->r_info))
  1793. {
  1794. @@ -64,8 +64,3 @@
  1795. _dl_exit(1);
  1796. }
  1797. }
  1798. -
  1799. -/* Transfer control to the user's application, once the dynamic loader is
  1800. - * done. This routine has to exit the current function, then call the
  1801. - * _dl_elf_main function. */
  1802. -#define START() return _dl_elf_main
  1803. diff -urN uClibc-0.9.28.orig/ldso/ldso/i386/dl-syscalls.h uClibc-0.9.28/ldso/ldso/i386/dl-syscalls.h
  1804. --- uClibc-0.9.28.orig/ldso/ldso/i386/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  1805. +++ uClibc-0.9.28/ldso/ldso/i386/dl-syscalls.h 2006-04-28 00:14:35.000000000 -0600
  1806. @@ -1,5 +1,6 @@
  1807. /* We can't use the real errno in ldso, since it has not yet
  1808. * been dynamicly linked in yet. */
  1809. +#include "sys/syscall.h"
  1810. extern int _dl_errno;
  1811. +#undef __set_errno
  1812. #define __set_errno(X) {(_dl_errno) = (X);}
  1813. -#include "sys/syscall.h"
  1814. diff -urN uClibc-0.9.28.orig/ldso/ldso/i386/dl-sysdep.h uClibc-0.9.28/ldso/ldso/i386/dl-sysdep.h
  1815. --- uClibc-0.9.28.orig/ldso/ldso/i386/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  1816. +++ uClibc-0.9.28/ldso/ldso/i386/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  1817. @@ -25,8 +25,6 @@
  1818. struct elf_resolve;
  1819. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  1820. -#define do_rem(result, n, base) ((result) = (n) % (base))
  1821. -
  1822. /* 4096 bytes alignment */
  1823. #define PAGE_ALIGN 0xfffff000
  1824. #define ADDR_ALIGN 0xfff
  1825. @@ -44,16 +42,18 @@
  1826. /* Return the link-time address of _DYNAMIC. Conveniently, this is the
  1827. first element of the GOT. This must be inlined in a function which
  1828. uses global data. */
  1829. -static inline Elf32_Addr __attribute__ ((unused))
  1830. +static inline Elf32_Addr elf_machine_dynamic (void) attribute_unused;
  1831. +static inline Elf32_Addr
  1832. elf_machine_dynamic (void)
  1833. {
  1834. - register Elf32_Addr *got asm ("%ebx");
  1835. + register Elf32_Addr *got __asm__ ("%ebx");
  1836. return *got;
  1837. }
  1838. /* Return the run-time load address of the shared object. */
  1839. -static inline Elf32_Addr __attribute__ ((unused))
  1840. +static inline Elf32_Addr elf_machine_load_address (void) attribute_unused;
  1841. +static inline Elf32_Addr
  1842. elf_machine_load_address (void)
  1843. {
  1844. /* It doesn't matter what variable this is, the reference never makes
  1845. @@ -61,7 +61,7 @@
  1846. via the GOT to make sure the compiler initialized %ebx in time. */
  1847. extern int _dl_errno;
  1848. Elf32_Addr addr;
  1849. - asm ("leal _dl_start@GOTOFF(%%ebx), %0\n"
  1850. + __asm__ ("leal _dl_start@GOTOFF(%%ebx), %0\n"
  1851. "subl _dl_start@GOT(%%ebx), %0"
  1852. : "=r" (addr) : "m" (_dl_errno) : "cc");
  1853. return addr;
  1854. diff -urN uClibc-0.9.28.orig/ldso/ldso/i386/elfinterp.c uClibc-0.9.28/ldso/ldso/i386/elfinterp.c
  1855. --- uClibc-0.9.28.orig/ldso/ldso/i386/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  1856. +++ uClibc-0.9.28/ldso/ldso/i386/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  1857. @@ -67,12 +67,6 @@
  1858. strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  1859. symname = strtab + symtab[symtab_index].st_name;
  1860. - if (unlikely(reloc_type != R_386_JMP_SLOT)) {
  1861. - _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
  1862. - _dl_progname);
  1863. - _dl_exit(1);
  1864. - }
  1865. -
  1866. /* Address of the jump instruction to fix up. */
  1867. instr_addr = ((unsigned long)this_reloc->r_offset +
  1868. (unsigned long)tpnt->loadaddr);
  1869. @@ -81,7 +75,7 @@
  1870. /* Get the address of the GOT entry. */
  1871. new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
  1872. if (unlikely(!new_addr)) {
  1873. - _dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
  1874. + _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
  1875. _dl_exit(1);
  1876. }
  1877. @@ -147,15 +141,15 @@
  1878. int reloc_type = ELF32_R_TYPE(rpnt->r_info);
  1879. #if defined (__SUPPORT_LD_DEBUG__)
  1880. - _dl_dprintf(2, "can't handle reloc type %s\n",
  1881. - _dl_reltypes(reloc_type));
  1882. + _dl_dprintf(2, "can't handle reloc type '%s' in lib '%s'\n",
  1883. + _dl_reltypes(reloc_type), tpnt->libname);
  1884. #else
  1885. - _dl_dprintf(2, "can't handle reloc type %x\n",
  1886. - reloc_type);
  1887. + _dl_dprintf(2, "can't handle reloc type %x in lib '%s'\n",
  1888. + reloc_type, tpnt->libname);
  1889. #endif
  1890. - _dl_exit(-res);
  1891. + return res;
  1892. } else if (unlikely(res > 0)) {
  1893. - _dl_dprintf(2, "can't resolve symbol\n");
  1894. + _dl_dprintf(2, "can't resolve symbol in lib '%s'.\n", tpnt->libname);
  1895. return res;
  1896. }
  1897. }
  1898. @@ -191,10 +185,8 @@
  1899. * might have been intentional. We should not be linking local
  1900. * symbols here, so all bases should be covered.
  1901. */
  1902. - if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) {
  1903. - _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
  1904. - _dl_exit(1);
  1905. - };
  1906. + if (unlikely(!symbol_addr && ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK))
  1907. + return 1;
  1908. }
  1909. #if defined (__SUPPORT_LD_DEBUG__)
  1910. @@ -233,7 +225,7 @@
  1911. }
  1912. break;
  1913. default:
  1914. - return -1; /* Calls _dl_exit(1). */
  1915. + return -1;
  1916. }
  1917. #if defined (__SUPPORT_LD_DEBUG__)
  1918. @@ -273,7 +265,7 @@
  1919. *reloc_addr += (unsigned long)tpnt->loadaddr;
  1920. break;
  1921. default:
  1922. - return -1; /* Calls _dl_exit(1). */
  1923. + return -1;
  1924. }
  1925. #if defined (__SUPPORT_LD_DEBUG__)
  1926. diff -urN uClibc-0.9.28.orig/ldso/ldso/ldso.c uClibc-0.9.28/ldso/ldso/ldso.c
  1927. --- uClibc-0.9.28.orig/ldso/ldso/ldso.c 2006-05-02 10:47:27.000000000 -0600
  1928. +++ uClibc-0.9.28/ldso/ldso/ldso.c 2006-05-02 13:55:54.000000000 -0600
  1929. @@ -39,7 +39,7 @@
  1930. #define ALLOW_ZERO_PLTGOT
  1931. /* Pull in the value of _dl_progname */
  1932. -#include "dl-progname.h"
  1933. +#include LDSO_ELFINTERP
  1934. /* Global variables used within the shared library loader */
  1935. char *_dl_library_path = 0; /* Where we look for libraries */
  1936. @@ -74,7 +74,8 @@
  1937. * can set an internal breakpoint on it, so that we are notified when the
  1938. * address mapping is changed in some way.
  1939. */
  1940. -void _dl_debug_state(void)
  1941. +void _dl_debug_state(void);
  1942. +void _dl_debug_state()
  1943. {
  1944. }
  1945. @@ -82,9 +83,78 @@
  1946. static unsigned char *_dl_mmap_zero = 0; /* Also used by _dl_malloc */
  1947. static struct elf_resolve **init_fini_list;
  1948. -static int nlist; /* # items in init_fini_list */
  1949. +static unsigned int nlist; /* # items in init_fini_list */
  1950. extern void _start(void);
  1951. +#ifdef __UCLIBC_HAS_SSP__
  1952. +#ifndef __UCLIBC_HAS_SSP_COMPAT__
  1953. +#define __UCLIBC_HAS_SSP_COMPAT__ 1
  1954. +#endif
  1955. +# include <dl-osinfo.h>
  1956. +uintptr_t stack_chk_guard;
  1957. +# ifndef THREAD_SET_STACK_GUARD
  1958. +/* Only exported for architectures that don't store the stack guard canary
  1959. + * in local thread area. */
  1960. +uintptr_t __stack_chk_guard attribute_relro;
  1961. +# ifdef __UCLIBC_HAS_SSP_COMPAT__
  1962. +strong_alias(__stack_chk_guard,__guard)
  1963. +# endif
  1964. +# elif __UCLIBC_HAS_SSP_COMPAT__
  1965. +uintptr_t __guard attribute_relro;
  1966. +# endif
  1967. +#endif
  1968. +
  1969. +static void _dl_run_array_forward(unsigned long array, unsigned long size,
  1970. + ElfW(Addr) loadaddr)
  1971. +{
  1972. + if (array != 0) {
  1973. + unsigned int j;
  1974. + unsigned int jm;
  1975. + ElfW(Addr) *addrs;
  1976. + jm = size / sizeof (ElfW(Addr));
  1977. + addrs = (ElfW(Addr) *) (array + loadaddr);
  1978. + for (j = 0; j < jm; ++j) {
  1979. + void (*dl_elf_func) (void);
  1980. + dl_elf_func = (void (*)(void)) (intptr_t) addrs[j];
  1981. + (*dl_elf_func) ();
  1982. + }
  1983. + }
  1984. +}
  1985. +
  1986. +void _dl_run_init_array(struct elf_resolve *tpnt);
  1987. +void _dl_run_init_array(struct elf_resolve *tpnt)
  1988. +{
  1989. + _dl_run_array_forward(tpnt->dynamic_info[DT_INIT_ARRAY],
  1990. + tpnt->dynamic_info[DT_INIT_ARRAYSZ],
  1991. + tpnt->loadaddr);
  1992. +}
  1993. +
  1994. +void _dl_app_init_array(void);
  1995. +void _dl_app_init_array(void)
  1996. +{
  1997. + _dl_run_init_array(_dl_loaded_modules);
  1998. +}
  1999. +
  2000. +void _dl_run_fini_array(struct elf_resolve *tpnt);
  2001. +void _dl_run_fini_array(struct elf_resolve *tpnt)
  2002. +{
  2003. + if (tpnt->dynamic_info[DT_FINI_ARRAY]) {
  2004. + ElfW(Addr) *array = (ElfW(Addr) *) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI_ARRAY]);
  2005. + unsigned int i = (tpnt->dynamic_info[DT_FINI_ARRAYSZ] / sizeof(ElfW(Addr)));
  2006. + while (i-- > 0) {
  2007. + void (*dl_elf_func) (void);
  2008. + dl_elf_func = (void (*)(void)) (intptr_t) array[i];
  2009. + (*dl_elf_func) ();
  2010. + }
  2011. + }
  2012. +}
  2013. +
  2014. +void _dl_app_fini_array(void);
  2015. +void _dl_app_fini_array(void)
  2016. +{
  2017. + _dl_run_fini_array(_dl_loaded_modules);
  2018. +}
  2019. +
  2020. static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void)
  2021. {
  2022. int i;
  2023. @@ -95,6 +165,7 @@
  2024. if (tpnt->init_flag & FINI_FUNCS_CALLED)
  2025. continue;
  2026. tpnt->init_flag |= FINI_FUNCS_CALLED;
  2027. + _dl_run_fini_array(tpnt);
  2028. if (tpnt->dynamic_info[DT_FINI]) {
  2029. void (*dl_elf_func) (void);
  2030. @@ -112,7 +183,8 @@
  2031. ElfW(Phdr) *ppnt;
  2032. ElfW(Dyn) *dpnt;
  2033. char *lpntstr;
  2034. - int i, goof = 0, unlazy = 0, trace_loaded_objects = 0;
  2035. + unsigned int i;
  2036. + int unlazy = 0, trace_loaded_objects = 0;
  2037. struct dyn_elf *rpnt;
  2038. struct elf_resolve *tcurr;
  2039. struct elf_resolve *tpnt1;
  2040. @@ -128,6 +200,7 @@
  2041. * setup so we can use _dl_dprintf() to print debug noise
  2042. * instead of the SEND_STDERR macros used in dl-startup.c */
  2043. + _dl_memset(app_tpnt, 0x00, sizeof(*app_tpnt));
  2044. /* Store the page size for later use */
  2045. _dl_pagesize = (auxvt[AT_PAGESZ].a_un.a_val) ? (size_t) auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
  2046. @@ -168,8 +241,8 @@
  2047. * Note that for SUID programs we ignore the settings in
  2048. * LD_LIBRARY_PATH.
  2049. */
  2050. - if ((auxvt[AT_UID].a_un.a_val == -1 && _dl_suid_ok()) ||
  2051. - (auxvt[AT_UID].a_un.a_val != -1 &&
  2052. + if ((auxvt[AT_UID].a_un.a_val == (size_t)-1 && _dl_suid_ok()) ||
  2053. + (auxvt[AT_UID].a_un.a_val != (size_t)-1 &&
  2054. auxvt[AT_UID].a_un.a_val == auxvt[AT_EUID].a_un.a_val &&
  2055. auxvt[AT_GID].a_un.a_val == auxvt[AT_EGID].a_un.a_val)) {
  2056. _dl_secure = 0;
  2057. @@ -196,6 +269,20 @@
  2058. unlazy = RTLD_NOW;
  2059. }
  2060. + /* sjhill: your TLS init should go before this */
  2061. +#ifdef __UCLIBC_HAS_SSP__
  2062. + /* Set up the stack checker's canary. */
  2063. + stack_chk_guard = _dl_setup_stack_chk_guard ();
  2064. +# ifdef THREAD_SET_STACK_GUARD
  2065. + THREAD_SET_STACK_GUARD (stack_chk_guard);
  2066. +# ifdef __UCLIBC_HAS_SSP_COMPAT__
  2067. + __guard = stack_chk_guard;
  2068. +# endif
  2069. +# else
  2070. + __stack_chk_guard = stack_chk_guard;
  2071. +# endif
  2072. +#endif
  2073. +
  2074. /* At this point we are now free to examine the user application,
  2075. * and figure out which libraries are supposed to be called. Until
  2076. * we have this list, we will not be completely ready for dynamic
  2077. @@ -206,12 +293,12 @@
  2078. * different from what the ELF header says for ET_DYN/PIE executables.
  2079. */
  2080. {
  2081. - int i;
  2082. - ElfW(Phdr) *ppnt = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
  2083. + unsigned int idx;
  2084. + ElfW(Phdr) *phdr = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
  2085. - for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++)
  2086. - if (ppnt->p_type == PT_PHDR) {
  2087. - app_tpnt->loadaddr = (ElfW(Addr)) (auxvt[AT_PHDR].a_un.a_val - ppnt->p_vaddr);
  2088. + for (idx = 0; idx < auxvt[AT_PHNUM].a_un.a_val; idx++, phdr++)
  2089. + if (phdr->p_type == PT_PHDR) {
  2090. + app_tpnt->loadaddr = (ElfW(Addr)) (auxvt[AT_PHDR].a_un.a_val - phdr->p_vaddr);
  2091. break;
  2092. }
  2093. @@ -459,8 +546,8 @@
  2094. PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
  2095. _dl_close(fd);
  2096. if (preload == (caddr_t) -1) {
  2097. - _dl_dprintf(_dl_debug_file, "%s: can't map file '%s'\n",
  2098. - _dl_progname, LDSO_PRELOAD);
  2099. + _dl_dprintf(_dl_debug_file, "%s:%i: can't map '%s'\n",
  2100. + _dl_progname, __LINE__, LDSO_PRELOAD);
  2101. break;
  2102. }
  2103. @@ -528,15 +615,15 @@
  2104. nlist = 0;
  2105. for (tcurr = _dl_loaded_modules; tcurr; tcurr = tcurr->next) {
  2106. - ElfW(Dyn) *dpnt;
  2107. + ElfW(Dyn) *this_dpnt;
  2108. nlist++;
  2109. - for (dpnt = (ElfW(Dyn) *) tcurr->dynamic_addr; dpnt->d_tag; dpnt++) {
  2110. - if (dpnt->d_tag == DT_NEEDED) {
  2111. + for (this_dpnt = (ElfW(Dyn) *) tcurr->dynamic_addr; this_dpnt->d_tag; this_dpnt++) {
  2112. + if (this_dpnt->d_tag == DT_NEEDED) {
  2113. char *name;
  2114. struct init_fini_list *tmp;
  2115. - lpntstr = (char*) (tcurr->dynamic_info[DT_STRTAB] + dpnt->d_un.d_val);
  2116. + lpntstr = (char*) (tcurr->dynamic_info[DT_STRTAB] + this_dpnt->d_un.d_val);
  2117. name = _dl_get_last_path_component(lpntstr);
  2118. if (_dl_strcmp(name, UCLIBC_LDSO) == 0)
  2119. continue;
  2120. @@ -633,7 +720,7 @@
  2121. ElfW(Ehdr) *epnt = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
  2122. ElfW(Phdr) *myppnt = (ElfW(Phdr) *) (load_addr + epnt->e_phoff);
  2123. int j;
  2124. -
  2125. +
  2126. tpnt = _dl_add_elf_hash_table(tpnt->libname, (char *)load_addr,
  2127. tpnt->dynamic_info,
  2128. (unsigned long)tpnt->dynamic_addr,
  2129. @@ -703,16 +790,14 @@
  2130. * order so that COPY directives work correctly.
  2131. */
  2132. if (_dl_symbol_tables)
  2133. - goof += _dl_fixup(_dl_symbol_tables, unlazy);
  2134. + if (_dl_fixup(_dl_symbol_tables, unlazy))
  2135. + _dl_exit(-1);
  2136. for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
  2137. if (tpnt->relro_size)
  2138. _dl_protect_relro (tpnt);
  2139. }
  2140. -
  2141. -
  2142. -
  2143. /* OK, at this point things are pretty much ready to run. Now we need
  2144. * to touch up a few items that are required, and then we can let the
  2145. * user application have at it. Note that the dynamic linker itself
  2146. @@ -746,6 +831,14 @@
  2147. /* Notify the debugger we have added some objects. */
  2148. _dl_debug_addr->r_state = RT_ADD;
  2149. _dl_debug_state();
  2150. +
  2151. + /* Run pre-initialization functions for the executable. */
  2152. + _dl_run_array_forward(_dl_loaded_modules->dynamic_info[DT_PREINIT_ARRAY],
  2153. + _dl_loaded_modules->dynamic_info[DT_PREINIT_ARRAYSZ],
  2154. + _dl_loaded_modules->loadaddr);
  2155. +
  2156. + /* Run initialization functions for loaded objects. For the
  2157. + main executable, they will be run from __uClibc_main. */
  2158. for (i = nlist; i; --i) {
  2159. tpnt = init_fini_list[i-1];
  2160. tpnt->init_fini = NULL; /* Clear, since alloca was used */
  2161. @@ -762,17 +855,9 @@
  2162. (*dl_elf_func) ();
  2163. }
  2164. - }
  2165. -#ifdef _DL_FINI_CRT_COMPAT
  2166. - /* arches that have moved their ldso FINI handling should skip this part */
  2167. - {
  2168. - int (*_dl_atexit) (void *) = (int (*)(void *)) (intptr_t) _dl_find_hash("atexit",
  2169. - _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT);
  2170. - if (_dl_atexit)
  2171. - (*_dl_atexit) (_dl_fini);
  2172. + _dl_run_init_array(tpnt);
  2173. }
  2174. -#endif
  2175. /* Find the real malloc function and make ldso functions use that from now on */
  2176. _dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash("malloc",
  2177. diff -urN uClibc-0.9.28.orig/ldso/ldso/m68k/dl-startup.h uClibc-0.9.28/ldso/ldso/m68k/dl-startup.h
  2178. --- uClibc-0.9.28.orig/ldso/ldso/m68k/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  2179. +++ uClibc-0.9.28/ldso/ldso/m68k/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  2180. @@ -4,23 +4,48 @@
  2181. * Copyright (C) 2005 by Erik Andersen <andersen@codepoet.org>
  2182. */
  2183. -asm(
  2184. - " .text\n"
  2185. - " .globl _start\n"
  2186. - " .type _start,@function\n"
  2187. - "_start:\n"
  2188. - " .set _start,_dl_start\n"
  2189. - " .size _start,.-_start\n"
  2190. - " .previous\n"
  2191. -);
  2192. +asm ("\
  2193. + .text\n\
  2194. + .globl _start\n\
  2195. + .type _start,@function\n\
  2196. +_start:\n\
  2197. + move.l %sp, -(%sp)\n\
  2198. + jbsr _dl_start\n\
  2199. + addq.l #4, %sp\n\
  2200. + /* FALLTHRU */\n\
  2201. +\n\
  2202. + .globl _dl_start_user\n\
  2203. +.type _dl_start_user,@function\n\
  2204. +_dl_start_user:\n\
  2205. + # Save the user entry point address in %a4.\n\
  2206. + move.l %d0, %a4\n\
  2207. + # See if we were run as a command with the executable file\n\
  2208. + # name as an extra leading argument.\n\
  2209. + move.l _dl_skip_args(%pc), %d0\n\
  2210. + # Pop the original argument count\n\
  2211. + move.l (%sp)+, %d1\n\
  2212. + # Subtract _dl_skip_args from it.\n\
  2213. + sub.l %d0, %d1\n\
  2214. + # Adjust the stack pointer to skip _dl_skip_args words.\n\
  2215. + lea (%sp, %d0*4), %sp\n\
  2216. + # Push back the modified argument count.\n\
  2217. + move.l %d1, -(%sp)\n\
  2218. + # Pass our finalizer function to the user in %a1.\n\
  2219. + lea _dl_fini(%pc), %a1\n\
  2220. + # Initialize %fp with the stack pointer.\n\
  2221. + move.l %sp, %fp\n\
  2222. + # Jump to the user's entry point.\n\
  2223. + jmp (%a4)\n\
  2224. + .size _dl_start_user, . - _dl_start_user\n\
  2225. + .previous");
  2226. /* Get a pointer to the argv array. On many platforms this can be just
  2227. * the address if the first argument, on other platforms we need to
  2228. * do something a little more subtle here. */
  2229. -#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned int *) & ARGS)
  2230. +#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS) + 1)
  2231. /* Handle relocation of the symbols in the dynamic loader. */
  2232. -static inline
  2233. +static __always_inline
  2234. void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
  2235. unsigned long symbol_addr, unsigned long load_addr, Elf32_Sym *symtab)
  2236. {
  2237. @@ -59,12 +84,3 @@
  2238. _dl_exit (1);
  2239. }
  2240. }
  2241. -
  2242. -/* Transfer control to the user's application, once the dynamic loader is
  2243. - * done. This routine has to exit the current function, then call the
  2244. - * _dl_elf_main function. */
  2245. -#define START() \
  2246. - __asm__ volatile ( \
  2247. - "unlk %%a6\n\t" \
  2248. - "jmp %0@" \
  2249. - : : "a" (_dl_elf_main));
  2250. diff -urN uClibc-0.9.28.orig/ldso/ldso/m68k/dl-syscalls.h uClibc-0.9.28/ldso/ldso/m68k/dl-syscalls.h
  2251. --- uClibc-0.9.28.orig/ldso/ldso/m68k/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  2252. +++ uClibc-0.9.28/ldso/ldso/m68k/dl-syscalls.h 2006-04-28 00:14:35.000000000 -0600
  2253. @@ -1,5 +1,6 @@
  2254. /* We can't use the real errno in ldso, since it has not yet
  2255. * been dynamicly linked in yet. */
  2256. +#include "sys/syscall.h"
  2257. extern int _dl_errno;
  2258. +#undef __set_errno
  2259. #define __set_errno(X) {(_dl_errno) = (X);}
  2260. -#include "sys/syscall.h"
  2261. diff -urN uClibc-0.9.28.orig/ldso/ldso/m68k/dl-sysdep.h uClibc-0.9.28/ldso/ldso/m68k/dl-sysdep.h
  2262. --- uClibc-0.9.28.orig/ldso/ldso/m68k/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  2263. +++ uClibc-0.9.28/ldso/ldso/m68k/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  2264. @@ -25,10 +25,6 @@
  2265. struct elf_resolve;
  2266. extern unsigned int _dl_linux_resolver (struct elf_resolve *, int);
  2267. -/* Define this because we do not want to call .udiv in the library.
  2268. - Not needed for m68k. */
  2269. -#define do_rem(result, n, base) ((result) = (n) % (base))
  2270. -
  2271. /* 4096 bytes alignment */
  2272. #define PAGE_ALIGN 0xfffff000
  2273. #define ADDR_ALIGN 0xfff
  2274. diff -urN uClibc-0.9.28.orig/ldso/ldso/m68k/elfinterp.c uClibc-0.9.28/ldso/ldso/m68k/elfinterp.c
  2275. --- uClibc-0.9.28.orig/ldso/ldso/m68k/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  2276. +++ uClibc-0.9.28/ldso/ldso/m68k/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  2277. @@ -40,6 +40,8 @@
  2278. a more than adequate job of explaining everything required to get this
  2279. working. */
  2280. +#include "ldso.h"
  2281. +
  2282. extern int _dl_linux_resolve(void);
  2283. unsigned int
  2284. @@ -48,20 +50,20 @@
  2285. int reloc_type;
  2286. ELF_RELOC *this_reloc;
  2287. char *strtab;
  2288. - Elf32_Sym *symtab;
  2289. + ElfW(Sym) *symtab;
  2290. int symtab_index;
  2291. - ELF_RELOC *rel_addr;
  2292. + char *rel_addr;
  2293. char *new_addr;
  2294. char **got_addr;
  2295. - unsigned int instr_addr;
  2296. + ElfW(Addr) instr_addr;
  2297. char *symname;
  2298. - rel_addr = (ELF_RELOC *)tpnt->dynamic_info[DT_JMPREL];
  2299. - this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
  2300. - reloc_type = ELF32_R_TYPE(this_reloc->r_info);
  2301. - symtab_index = ELF32_R_SYM(this_reloc->r_info);
  2302. + rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
  2303. + this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
  2304. + reloc_type = ELF_R_TYPE(this_reloc->r_info);
  2305. + symtab_index = ELF_R_SYM(this_reloc->r_info);
  2306. - symtab = (Elf32_Sym *)(intptr_t)tpnt->dynamic_info[DT_SYMTAB];
  2307. + symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
  2308. strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  2309. symname = strtab + symtab[symtab_index].st_name;
  2310. @@ -72,7 +74,7 @@
  2311. }
  2312. /* Address of the jump instruction to fix up. */
  2313. - instr_addr = ((int)this_reloc->r_offset + (int)tpnt->loadaddr);
  2314. + instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
  2315. got_addr = (char **)instr_addr;
  2316. /* Get the address of the GOT entry. */
  2317. @@ -88,159 +90,237 @@
  2318. _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
  2319. if (_dl_debug_detail)
  2320. _dl_dprintf(_dl_debug_file,
  2321. - "\n\tpatched: %x ==> %x @ %x",
  2322. + "\tpatched: %x ==> %x @ %x\n",
  2323. *got_addr, new_addr, got_addr);
  2324. }
  2325. }
  2326. - if (!_dl_debug_nofixups) {
  2327. - *got_addr = new_addr;
  2328. - }
  2329. -#else
  2330. - *got_addr = new_addr;
  2331. + if (!_dl_debug_nofixups)
  2332. #endif
  2333. + *got_addr = new_addr;
  2334. - return (unsigned int)new_addr;
  2335. + return (unsigned int)new_addr;
  2336. }
  2337. -void
  2338. -_dl_parse_lazy_relocation_information(struct dyn_elf *arg_rpnt,
  2339. - unsigned long rel_addr, unsigned long rel_size)
  2340. +static int
  2341. +_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
  2342. + unsigned long rel_addr, unsigned long rel_size,
  2343. + int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
  2344. + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
  2345. {
  2346. - int i;
  2347. + unsigned int i;
  2348. char *strtab;
  2349. - int reloc_type;
  2350. + ElfW(Sym) *symtab;
  2351. + ELF_RELOC *rpnt;
  2352. int symtab_index;
  2353. - Elf32_Sym *symtab;
  2354. - Elf32_Rela *rpnt;
  2355. - unsigned int *reloc_addr;
  2356. - struct elf_resolve *tpnt = arg_rpnt->dyn;
  2357. -
  2358. - /* Now parse the relocation information. */
  2359. - rpnt = (Elf32_Rela *)rel_addr;
  2360. - rel_size = rel_size / sizeof (Elf32_Rela);
  2361. - symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
  2362. + /* Parse the relocation information. */
  2363. + rpnt = (ELF_RELOC *)rel_addr;
  2364. + rel_size /= sizeof(ELF_RELOC);
  2365. +
  2366. + symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
  2367. strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  2368. for (i = 0; i < rel_size; i++, rpnt++) {
  2369. - reloc_addr = (int *) (tpnt->loadaddr + (int) rpnt->r_offset);
  2370. - reloc_type = ELF32_R_TYPE (rpnt->r_info);
  2371. - symtab_index = ELF32_R_SYM (rpnt->r_info);
  2372. + int res;
  2373. - switch (reloc_type)
  2374. - {
  2375. - case R_68K_NONE:
  2376. - break;
  2377. - case R_68K_JMP_SLOT:
  2378. - *reloc_addr += (unsigned int) tpnt->loadaddr;
  2379. - break;
  2380. - default:
  2381. - _dl_dprintf (2, "%s: (LAZY) can't handle reloc type ", _dl_progname);
  2382. + symtab_index = ELF_R_SYM(rpnt->r_info);
  2383. +
  2384. + debug_sym(symtab, strtab, symtab_index);
  2385. + debug_reloc(symtab, strtab, rpnt);
  2386. +
  2387. + res = reloc_fnc(tpnt, scope, rpnt, symtab, strtab);
  2388. +
  2389. + if (res == 0)
  2390. + continue;
  2391. +
  2392. + _dl_dprintf(2, "\n%s: ", _dl_progname);
  2393. +
  2394. + if (symtab_index)
  2395. + _dl_dprintf(2, "symbol '%s': ",
  2396. + strtab + symtab[symtab_index].st_name);
  2397. +
  2398. + if (unlikely(res < 0)) {
  2399. + int reloc_type = ELF_R_TYPE(rpnt->r_info);
  2400. +
  2401. + _dl_dprintf(2, "can't handle reloc type "
  2402. #if defined (__SUPPORT_LD_DEBUG__)
  2403. - _dl_dprintf (2, "%s ", _dl_reltypes_tab[reloc_type]);
  2404. + "%s\n", _dl_reltypes(reloc_type));
  2405. +#else
  2406. + "%x\n", reloc_type);
  2407. #endif
  2408. - if (symtab_index)
  2409. - _dl_dprintf (2, "'%s'", strtab + symtab[symtab_index].st_name);
  2410. - _dl_dprintf (2, "\n");
  2411. - _dl_exit (1);
  2412. + _dl_exit(-res);
  2413. + } else if (unlikely(res > 0)) {
  2414. + _dl_dprintf(2, "can't resolve symbol\n");
  2415. + return res;
  2416. }
  2417. }
  2418. +
  2419. + return 0;
  2420. }
  2421. -int
  2422. -_dl_parse_relocation_information(struct dyn_elf *arg_rpnt,
  2423. - unsigned long rel_addr, unsigned long rel_size)
  2424. +static int
  2425. +_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
  2426. + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
  2427. {
  2428. - int i;
  2429. - char *strtab;
  2430. int reloc_type;
  2431. - int goof = 0;
  2432. - Elf32_Sym *symtab;
  2433. - Elf32_Rela *rpnt;
  2434. - unsigned int *reloc_addr;
  2435. - unsigned int symbol_addr;
  2436. int symtab_index;
  2437. - struct elf_resolve *tpnt = arg_rpnt->dyn;
  2438. - /* Now parse the relocation information */
  2439. + char *symname;
  2440. + ElfW(Sym) *sym;
  2441. + ElfW(Addr) *reloc_addr;
  2442. + ElfW(Addr) symbol_addr;
  2443. +#if defined (__SUPPORT_LD_DEBUG__)
  2444. + ElfW(Addr) old_val;
  2445. +#endif
  2446. - rpnt = (Elf32_Rela *)rel_addr;
  2447. - rel_size = rel_size / sizeof (Elf32_Rela);
  2448. + reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
  2449. + reloc_type = ELF_R_TYPE(rpnt->r_info);
  2450. + symtab_index = ELF_R_SYM(rpnt->r_info);
  2451. + sym = &symtab[symtab_index];
  2452. + symbol_addr = 0;
  2453. + symname = strtab + sym->st_name;
  2454. +
  2455. + if (symtab_index) {
  2456. + symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
  2457. + elf_machine_type_class(reloc_type));
  2458. + /*
  2459. + * We want to allow undefined references to weak symbols - this
  2460. + * might have been intentional. We should not be linking local
  2461. + * symbols here, so all bases should be covered.
  2462. + */
  2463. + if (unlikely(!symbol_addr && ELF_ST_BIND(sym->st_info) != STB_WEAK)) {
  2464. + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
  2465. + _dl_exit(1);
  2466. + };
  2467. + }
  2468. - symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
  2469. - strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  2470. +#if defined (__SUPPORT_LD_DEBUG__)
  2471. + old_val = *reloc_addr;
  2472. +#endif
  2473. - for (i = 0; i < rel_size; i++, rpnt++) {
  2474. - reloc_addr = (int *) (tpnt->loadaddr + (int) rpnt->r_offset);
  2475. - reloc_type = ELF32_R_TYPE (rpnt->r_info);
  2476. - symtab_index = ELF32_R_SYM (rpnt->r_info);
  2477. - symbol_addr = 0;
  2478. - if (symtab_index) {
  2479. - symbol_addr = (unsigned int)
  2480. - _dl_find_hash (strtab + symtab[symtab_index].st_name,
  2481. - tpnt->symbol_scope, tpnt,
  2482. - elf_machine_type_class(reloc_type));
  2483. -
  2484. - /* We want to allow undefined references to weak symbols -
  2485. - this might have been intentional. We should not be
  2486. - linking local symbols here, so all bases should be
  2487. - covered. */
  2488. - if (!symbol_addr
  2489. - && ELF32_ST_BIND (symtab[symtab_index].st_info) != STB_WEAK)
  2490. - {
  2491. - _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
  2492. - _dl_progname, strtab + symtab[symtab_index].st_name);
  2493. - _dl_exit (1);
  2494. - }
  2495. - }
  2496. - switch (reloc_type)
  2497. - {
  2498. - case R_68K_NONE:
  2499. - break;
  2500. - case R_68K_8:
  2501. - *(char *) reloc_addr = symbol_addr + rpnt->r_addend;
  2502. - break;
  2503. - case R_68K_16:
  2504. - *(short *) reloc_addr = symbol_addr + rpnt->r_addend;
  2505. - break;
  2506. - case R_68K_32:
  2507. - *reloc_addr = symbol_addr + rpnt->r_addend;
  2508. - break;
  2509. - case R_68K_PC8:
  2510. - *(char *) reloc_addr = (symbol_addr + rpnt->r_addend
  2511. - - (unsigned int) reloc_addr);
  2512. - break;
  2513. - case R_68K_PC16:
  2514. - *(short *) reloc_addr = (symbol_addr + rpnt->r_addend
  2515. - - (unsigned int) reloc_addr);
  2516. - break;
  2517. - case R_68K_PC32:
  2518. - *reloc_addr = (symbol_addr + rpnt->r_addend
  2519. - - (unsigned int) reloc_addr);
  2520. - break;
  2521. - case R_68K_GLOB_DAT:
  2522. - case R_68K_JMP_SLOT:
  2523. - *reloc_addr = symbol_addr;
  2524. - break;
  2525. - case R_68K_RELATIVE:
  2526. - *reloc_addr = ((unsigned int) tpnt->loadaddr
  2527. - /* Compatibility kludge. */
  2528. - + (rpnt->r_addend ? : *reloc_addr));
  2529. - break;
  2530. - case R_68K_COPY:
  2531. + switch (reloc_type) {
  2532. + case R_68K_NONE:
  2533. + break;
  2534. + case R_68K_8:
  2535. + *(char *) reloc_addr = symbol_addr + rpnt->r_addend;
  2536. + break;
  2537. + case R_68K_16:
  2538. + *(short *) reloc_addr = symbol_addr + rpnt->r_addend;
  2539. + break;
  2540. + case R_68K_32:
  2541. + *reloc_addr = symbol_addr + rpnt->r_addend;
  2542. + break;
  2543. + case R_68K_PC8:
  2544. + *(char *) reloc_addr = (symbol_addr + rpnt->r_addend
  2545. + - (unsigned int) reloc_addr);
  2546. + break;
  2547. + case R_68K_PC16:
  2548. + *(short *) reloc_addr = (symbol_addr + rpnt->r_addend
  2549. + - (unsigned int) reloc_addr);
  2550. + break;
  2551. + case R_68K_PC32:
  2552. + *reloc_addr = (symbol_addr + rpnt->r_addend
  2553. + - (unsigned int) reloc_addr);
  2554. + break;
  2555. + case R_68K_GLOB_DAT:
  2556. + case R_68K_JMP_SLOT:
  2557. + *reloc_addr = symbol_addr + rpnt->r_addend;
  2558. + break;
  2559. + /* handled by elf_machine_relative()
  2560. + case R_68K_RELATIVE:
  2561. + *reloc_addr = ((unsigned int) tpnt->loadaddr
  2562. + / * Compatibility kludge. * /
  2563. + + (rpnt->r_addend ? : *reloc_addr));
  2564. + */
  2565. + break;
  2566. + case R_68K_COPY:
  2567. + if (symbol_addr) {
  2568. +#if defined (__SUPPORT_LD_DEBUG__)
  2569. + if (_dl_debug_move)
  2570. + _dl_dprintf(_dl_debug_file,
  2571. + "\t%s move %d bytes from %x to %x\n",
  2572. + symname, sym->st_size,
  2573. + symbol_addr, reloc_addr);
  2574. +#endif
  2575. _dl_memcpy ((void *) reloc_addr,
  2576. (void *) symbol_addr,
  2577. - symtab[symtab_index].st_size);
  2578. - break;
  2579. - default:
  2580. - _dl_dprintf (2, "%s: can't handle reloc type ", _dl_progname);
  2581. -#if defined (__SUPPORT_LD_DEBUG__)
  2582. - _dl_dprintf (2, "%s ", _dl_reltypes_tab[reloc_type]);
  2583. -#endif
  2584. - if (symtab_index)
  2585. - _dl_dprintf (2, "'%s'", strtab + symtab[symtab_index].st_name);
  2586. - _dl_dprintf (2, "\n");
  2587. - _dl_exit (1);
  2588. - }
  2589. + sym->st_size);
  2590. + } else
  2591. + _dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
  2592. + break;
  2593. +
  2594. + default:
  2595. + return -1; /* Calls _dl_exit(1). */
  2596. + }
  2597. +
  2598. +#if defined (__SUPPORT_LD_DEBUG__)
  2599. + if (_dl_debug_reloc && _dl_debug_detail)
  2600. + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
  2601. + old_val, *reloc_addr, reloc_addr);
  2602. +#endif
  2603. +
  2604. + return 0;
  2605. +}
  2606. +
  2607. +#undef LAZY_RELOC_WORKS
  2608. +#ifdef LAZY_RELOC_WORKS
  2609. +static int
  2610. +_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
  2611. + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
  2612. +{
  2613. + int reloc_type;
  2614. + int symtab_index;
  2615. + ElfW(Addr) *reloc_addr;
  2616. +#if defined (__SUPPORT_LD_DEBUG__)
  2617. + ElfW(Addr) old_val;
  2618. +#endif
  2619. +
  2620. + (void)scope;
  2621. + symtab_index = ELF_R_SYM(rpnt->r_info);
  2622. + (void)strtab;
  2623. +
  2624. + reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
  2625. + reloc_type = ELF_R_TYPE(rpnt->r_info);
  2626. +
  2627. +#if defined (__SUPPORT_LD_DEBUG__)
  2628. + old_val = *reloc_addr;
  2629. +#endif
  2630. +
  2631. + switch (reloc_type) {
  2632. + case R_68K_NONE:
  2633. + break;
  2634. + case R_68K_JMP_SLOT:
  2635. + *reloc_addr += (unsigned int) tpnt->loadaddr;
  2636. + break;
  2637. + default:
  2638. + _dl_exit(1);
  2639. }
  2640. - return goof;
  2641. +
  2642. +#if defined (__SUPPORT_LD_DEBUG__)
  2643. + if (_dl_debug_reloc && _dl_debug_detail)
  2644. + _dl_dprintf(_dl_debug_file, "\tpatched_lazy: %x ==> %x @ %x\n",
  2645. + old_val, *reloc_addr, reloc_addr);
  2646. +#endif
  2647. +
  2648. + return 0;
  2649. +}
  2650. +#endif
  2651. +
  2652. +void
  2653. +_dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
  2654. + unsigned long rel_addr,
  2655. + unsigned long rel_size)
  2656. +{
  2657. +#ifdef LAZY_RELOC_WORKS
  2658. + (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
  2659. +#else
  2660. + _dl_parse_relocation_information(rpnt, rel_addr, rel_size);
  2661. +#endif
  2662. +}
  2663. +
  2664. +int
  2665. +_dl_parse_relocation_information(struct dyn_elf *rpnt,
  2666. + unsigned long rel_addr,
  2667. + unsigned long rel_size)
  2668. +{
  2669. + return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
  2670. }
  2671. diff -urN uClibc-0.9.28.orig/ldso/ldso/m68k/resolve.S uClibc-0.9.28/ldso/ldso/m68k/resolve.S
  2672. --- uClibc-0.9.28.orig/ldso/ldso/m68k/resolve.S 2006-05-02 10:47:27.000000000 -0600
  2673. +++ uClibc-0.9.28/ldso/ldso/m68k/resolve.S 2006-04-28 00:14:35.000000000 -0600
  2674. @@ -8,14 +8,16 @@
  2675. .globl _dl_linux_resolve
  2676. .type _dl_linux_resolve,@function
  2677. _dl_linux_resolve:
  2678. - moveml %a0/%a1,%sp@-
  2679. -#ifdef __PIC__
  2680. - bsrl _dl_linux_resolver@PLTPC
  2681. -#else
  2682. - jbsr _dl_linux_resolver
  2683. -#endif
  2684. - moveml %sp@+,%a0/%a1
  2685. - addql #8,%sp
  2686. - jmp @(%d0)
  2687. -.LFE2:
  2688. - .size _dl_linux_resolve,.LFE2-_dl_linux_resolve
  2689. + # Save %a0 (struct return address) and %a1.
  2690. + move.l %a0, -(%sp)
  2691. + move.l %a1, -(%sp)
  2692. + # Call the real address resolver.
  2693. + jbsr _dl_linux_resolver
  2694. + # Restore register %a0 and %a1.
  2695. + move.l (%sp)+, %a1
  2696. + move.l (%sp)+, %a0
  2697. + # Pop parameters
  2698. + addq.l #8, %sp
  2699. + # Call real function.
  2700. + jmp (%d0)
  2701. +.size _dl_linux_resolve,.-_dl_linux_resolve
  2702. diff -urN uClibc-0.9.28.orig/ldso/ldso/mips/dl-startup.h uClibc-0.9.28/ldso/ldso/mips/dl-startup.h
  2703. --- uClibc-0.9.28.orig/ldso/ldso/mips/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  2704. +++ uClibc-0.9.28/ldso/ldso/mips/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  2705. @@ -136,13 +136,3 @@
  2706. SEND_STDERR("Aiieeee!"); \
  2707. _dl_exit(1); \
  2708. }
  2709. -
  2710. -
  2711. -/*
  2712. - * Transfer control to the user's application, once the dynamic loader
  2713. - * is done. This routine has to exit the current function, then
  2714. - * call the _dl_elf_main function. For MIPS, we do it in assembly
  2715. - * because the stack doesn't get properly restored otherwise. Got look
  2716. - * at boot1_arch.h
  2717. - */
  2718. -#define START() return _dl_elf_main
  2719. diff -urN uClibc-0.9.28.orig/ldso/ldso/mips/dl-syscalls.h uClibc-0.9.28/ldso/ldso/mips/dl-syscalls.h
  2720. --- uClibc-0.9.28.orig/ldso/ldso/mips/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  2721. +++ uClibc-0.9.28/ldso/ldso/mips/dl-syscalls.h 2006-05-02 13:39:25.000000000 -0600
  2722. @@ -1,7 +1,8 @@
  2723. /* We can't use the real errno in ldso, since it has not yet
  2724. * been dynamicly linked in yet. */
  2725. +#define __UCLIBC_MMAP_HAS_6_ARGS__
  2726. +
  2727. +#include "sys/syscall.h"
  2728. extern int _dl_errno;
  2729. +#undef __set_errno
  2730. #define __set_errno(X) {(_dl_errno) = (X);}
  2731. -#include "sys/syscall.h"
  2732. -
  2733. -#define MMAP_HAS_6_ARGS
  2734. diff -urN uClibc-0.9.28.orig/ldso/ldso/mips/dl-sysdep.h uClibc-0.9.28/ldso/ldso/mips/dl-sysdep.h
  2735. --- uClibc-0.9.28.orig/ldso/ldso/mips/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  2736. +++ uClibc-0.9.28/ldso/ldso/mips/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  2737. @@ -30,7 +30,7 @@
  2738. /* Initialization sequence for the application/library GOT. */
  2739. #define INIT_GOT(GOT_BASE,MODULE) \
  2740. do { \
  2741. - unsigned long i; \
  2742. + unsigned long idx; \
  2743. \
  2744. /* Check if this is the dynamic linker itself */ \
  2745. if (MODULE->libtype == program_interpreter) \
  2746. @@ -41,9 +41,9 @@
  2747. GOT_BASE[1] = (unsigned long) MODULE; \
  2748. \
  2749. /* Add load address displacement to all local GOT entries */ \
  2750. - i = 2; \
  2751. - while (i < MODULE->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX]) \
  2752. - GOT_BASE[i++] += (unsigned long) MODULE->loadaddr; \
  2753. + idx = 2; \
  2754. + while (idx < MODULE->dynamic_info[DT_MIPS_LOCAL_GOTNO_IDX]) \
  2755. + GOT_BASE[idx++] += (unsigned long) MODULE->loadaddr; \
  2756. \
  2757. } while (0)
  2758. @@ -63,8 +63,6 @@
  2759. struct elf_resolve;
  2760. void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy);
  2761. -#define do_rem(result, n, base) ((result) = (n) % (base))
  2762. -
  2763. /* 4096 bytes alignment */
  2764. #define PAGE_ALIGN 0xfffff000
  2765. #define ADDR_ALIGN 0xfff
  2766. diff -urN uClibc-0.9.28.orig/ldso/ldso/mips/elfinterp.c uClibc-0.9.28/ldso/ldso/mips/elfinterp.c
  2767. --- uClibc-0.9.28.orig/ldso/ldso/mips/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  2768. +++ uClibc-0.9.28/ldso/ldso/mips/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  2769. @@ -27,6 +27,8 @@
  2770. * SUCH DAMAGE.
  2771. */
  2772. +#include "ldso.h"
  2773. +
  2774. extern int _dl_runtime_resolve(void);
  2775. #define OFFSET_GP_GOT 0x7ff0
  2776. @@ -146,7 +148,6 @@
  2777. break;
  2778. default:
  2779. {
  2780. - int reloc_type = ELF32_R_TYPE(rpnt->r_info);
  2781. _dl_dprintf(2, "\n%s: ",_dl_progname);
  2782. if (symtab_index)
  2783. diff -urN uClibc-0.9.28.orig/ldso/ldso/powerpc/dl-startup.h uClibc-0.9.28/ldso/ldso/powerpc/dl-startup.h
  2784. --- uClibc-0.9.28.orig/ldso/ldso/powerpc/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  2785. +++ uClibc-0.9.28/ldso/ldso/powerpc/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  2786. @@ -42,8 +42,10 @@
  2787. " bne 2b\n"
  2788. " addi 6,6,4\n"
  2789. #endif
  2790. - /* Pass a termination function pointer (in this case _dl_fini) in r7. */
  2791. - " lwz 7,_dl_fini@got(31)\n"
  2792. + /* Pass a termination function pointer (in this case _dl_fini) in r3. */
  2793. + /* Paulus promized he would keep r3 zero in the exec ABI. */
  2794. + " lwz 3,_dl_fini@got(31)\n"
  2795. + " mr 7,3\n" /* Pass _dl_fini in r7 to maintain compat */
  2796. " bctr\n" /* Jump to entry point */
  2797. " .size _start,.-_start\n"
  2798. " .previous\n"
  2799. @@ -78,9 +80,3 @@
  2800. _dl_exit(100+ELF32_R_TYPE((RELP)->r_info));\
  2801. } \
  2802. }
  2803. -/*
  2804. - * Transfer control to the user's application, once the dynamic loader
  2805. - * is done. This routine has to exit the current function, then
  2806. - * call the _dl_elf_main function.
  2807. - */
  2808. -#define START() return _dl_elf_main
  2809. diff -urN uClibc-0.9.28.orig/ldso/ldso/powerpc/dl-syscalls.h uClibc-0.9.28/ldso/ldso/powerpc/dl-syscalls.h
  2810. --- uClibc-0.9.28.orig/ldso/ldso/powerpc/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  2811. +++ uClibc-0.9.28/ldso/ldso/powerpc/dl-syscalls.h 2006-05-02 13:39:14.000000000 -0600
  2812. @@ -1,251 +1,8 @@
  2813. -/*
  2814. - * This file contains the system call macros and syscall
  2815. - * numbers used by the shared library loader.
  2816. - */
  2817. -
  2818. -#define MMAP_HAS_6_ARGS
  2819. -
  2820. -#define __NR_exit 1
  2821. -#define __NR_read 3
  2822. -#define __NR_write 4
  2823. -#define __NR_open 5
  2824. -#define __NR_close 6
  2825. -#define __NR_getpid 20
  2826. -#define __NR_getuid 24
  2827. -#define __NR_geteuid 49
  2828. -#define __NR_getgid 47
  2829. -#define __NR_getegid 50
  2830. -#define __NR_readlink 85
  2831. -#define __NR_mmap 90
  2832. -#define __NR_munmap 91
  2833. -#define __NR_stat 106
  2834. -#define __NR_mprotect 125
  2835. -
  2836. -
  2837. /* We can't use the real errno in ldso, since it has not yet
  2838. * been dynamicly linked in yet. */
  2839. -extern int _dl_errno;
  2840. -
  2841. -/* Here are the macros which define how this platform makes
  2842. - * system calls. This particular variant does _not_ set
  2843. - * errno (note how it is disabled in __syscall_return) since
  2844. - * these will get called before the errno symbol is dynamicly
  2845. - * linked. */
  2846. -
  2847. -#undef __syscall_return
  2848. -#define __syscall_return(type) \
  2849. - return (__sc_err & 0x10000000 ? _dl_errno = __sc_ret, __sc_ret = -1 : 0), \
  2850. - (type) __sc_ret
  2851. -
  2852. -#undef __syscall_clobbers
  2853. -#define __syscall_clobbers \
  2854. - "r9", "r10", "r11", "r12"
  2855. - //"r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"
  2856. -
  2857. -#undef _syscall0
  2858. -#define _syscall0(type,name) \
  2859. -type name(void) \
  2860. -{ \
  2861. - unsigned long __sc_ret, __sc_err; \
  2862. - { \
  2863. - register unsigned long __sc_0 __asm__ ("r0"); \
  2864. - register unsigned long __sc_3 __asm__ ("r3"); \
  2865. - \
  2866. - __sc_0 = __NR_##name; \
  2867. - __asm__ __volatile__ \
  2868. - ("sc \n\t" \
  2869. - "mfcr %1 " \
  2870. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  2871. - : "0" (__sc_3), "1" (__sc_0) \
  2872. - : "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); \
  2873. - __sc_ret = __sc_3; \
  2874. - __sc_err = __sc_0; \
  2875. - } \
  2876. - __syscall_return (type); \
  2877. -}
  2878. -
  2879. -#undef _syscall1
  2880. -#define _syscall1(type,name,type1,arg1) \
  2881. -type name(type1 arg1) \
  2882. -{ \
  2883. - unsigned long __sc_ret, __sc_err; \
  2884. - { \
  2885. - register unsigned long __sc_0 __asm__ ("r0"); \
  2886. - register unsigned long __sc_3 __asm__ ("r3"); \
  2887. - \
  2888. - __sc_3 = (unsigned long) (arg1); \
  2889. - __sc_0 = __NR_##name; \
  2890. - __asm__ __volatile__ \
  2891. - ("sc \n\t" \
  2892. - "mfcr %1 " \
  2893. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  2894. - : "0" (__sc_3), "1" (__sc_0) \
  2895. - : "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); \
  2896. - __sc_ret = __sc_3; \
  2897. - __sc_err = __sc_0; \
  2898. - } \
  2899. - __syscall_return (type); \
  2900. -}
  2901. -
  2902. -#undef _syscall2
  2903. -#define _syscall2(type,name,type1,arg1,type2,arg2) \
  2904. -type name(type1 arg1, type2 arg2) \
  2905. -{ \
  2906. - unsigned long __sc_ret, __sc_err; \
  2907. - { \
  2908. - register unsigned long __sc_0 __asm__ ("r0"); \
  2909. - register unsigned long __sc_3 __asm__ ("r3"); \
  2910. - register unsigned long __sc_4 __asm__ ("r4"); \
  2911. - \
  2912. - __sc_3 = (unsigned long) (arg1); \
  2913. - __sc_4 = (unsigned long) (arg2); \
  2914. - __sc_0 = __NR_##name; \
  2915. - __asm__ __volatile__ \
  2916. - ("sc \n\t" \
  2917. - "mfcr %1 " \
  2918. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  2919. - : "0" (__sc_3), "1" (__sc_0), \
  2920. - "r" (__sc_4) \
  2921. - : "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); \
  2922. - __sc_ret = __sc_3; \
  2923. - __sc_err = __sc_0; \
  2924. - } \
  2925. - __syscall_return (type); \
  2926. -}
  2927. -
  2928. -#undef _syscall3
  2929. -#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  2930. -type name(type1 arg1, type2 arg2, type3 arg3) \
  2931. -{ \
  2932. - unsigned long __sc_ret, __sc_err; \
  2933. - { \
  2934. - register unsigned long __sc_0 __asm__ ("r0"); \
  2935. - register unsigned long __sc_3 __asm__ ("r3"); \
  2936. - register unsigned long __sc_4 __asm__ ("r4"); \
  2937. - register unsigned long __sc_5 __asm__ ("r5"); \
  2938. - \
  2939. - __sc_3 = (unsigned long) (arg1); \
  2940. - __sc_4 = (unsigned long) (arg2); \
  2941. - __sc_5 = (unsigned long) (arg3); \
  2942. - __sc_0 = __NR_##name; \
  2943. - __asm__ __volatile__ \
  2944. - ("sc \n\t" \
  2945. - "mfcr %1 " \
  2946. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  2947. - : "0" (__sc_3), "1" (__sc_0), \
  2948. - "r" (__sc_4), \
  2949. - "r" (__sc_5) \
  2950. - : "r6", "r7", "r8", "r9", "r10", "r11", "r12" ); \
  2951. - __sc_ret = __sc_3; \
  2952. - __sc_err = __sc_0; \
  2953. - } \
  2954. - __syscall_return (type); \
  2955. -}
  2956. -
  2957. -#undef _syscall4
  2958. -#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  2959. -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  2960. -{ \
  2961. - unsigned long __sc_ret, __sc_err; \
  2962. - { \
  2963. - register unsigned long __sc_0 __asm__ ("r0"); \
  2964. - register unsigned long __sc_3 __asm__ ("r3"); \
  2965. - register unsigned long __sc_4 __asm__ ("r4"); \
  2966. - register unsigned long __sc_5 __asm__ ("r5"); \
  2967. - register unsigned long __sc_6 __asm__ ("r6"); \
  2968. - \
  2969. - __sc_3 = (unsigned long) (arg1); \
  2970. - __sc_4 = (unsigned long) (arg2); \
  2971. - __sc_5 = (unsigned long) (arg3); \
  2972. - __sc_6 = (unsigned long) (arg4); \
  2973. - __sc_0 = __NR_##name; \
  2974. - __asm__ __volatile__ \
  2975. - ("sc \n\t" \
  2976. - "mfcr %1 " \
  2977. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  2978. - : "0" (__sc_3), "1" (__sc_0), \
  2979. - "r" (__sc_4), \
  2980. - "r" (__sc_5), \
  2981. - "r" (__sc_6) \
  2982. - : "r7", "r8", "r9", "r10", "r11", "r12" ); \
  2983. - __sc_ret = __sc_3; \
  2984. - __sc_err = __sc_0; \
  2985. - } \
  2986. - __syscall_return (type); \
  2987. -}
  2988. -
  2989. -#undef _syscall5
  2990. -#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  2991. -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
  2992. -{ \
  2993. - unsigned long __sc_ret, __sc_err; \
  2994. - { \
  2995. - register unsigned long __sc_0 __asm__ ("r0"); \
  2996. - register unsigned long __sc_3 __asm__ ("r3"); \
  2997. - register unsigned long __sc_4 __asm__ ("r4"); \
  2998. - register unsigned long __sc_5 __asm__ ("r5"); \
  2999. - register unsigned long __sc_6 __asm__ ("r6"); \
  3000. - register unsigned long __sc_7 __asm__ ("r7"); \
  3001. - \
  3002. - __sc_3 = (unsigned long) (arg1); \
  3003. - __sc_4 = (unsigned long) (arg2); \
  3004. - __sc_5 = (unsigned long) (arg3); \
  3005. - __sc_6 = (unsigned long) (arg4); \
  3006. - __sc_7 = (unsigned long) (arg5); \
  3007. - __sc_0 = __NR_##name; \
  3008. - __asm__ __volatile__ \
  3009. - ("sc \n\t" \
  3010. - "mfcr %1 " \
  3011. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  3012. - : "0" (__sc_3), "1" (__sc_0), \
  3013. - "r" (__sc_4), \
  3014. - "r" (__sc_5), \
  3015. - "r" (__sc_6), \
  3016. - "r" (__sc_7) \
  3017. - : "r8", "r9", "r10", "r11", "r12" ); \
  3018. - __sc_ret = __sc_3; \
  3019. - __sc_err = __sc_0; \
  3020. - } \
  3021. - __syscall_return (type); \
  3022. -}
  3023. -
  3024. -
  3025. -#undef _syscall6
  3026. -#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
  3027. -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
  3028. -{ \
  3029. - unsigned long __sc_ret, __sc_err; \
  3030. - { \
  3031. - register unsigned long __sc_0 __asm__ ("r0"); \
  3032. - register unsigned long __sc_3 __asm__ ("r3"); \
  3033. - register unsigned long __sc_4 __asm__ ("r4"); \
  3034. - register unsigned long __sc_5 __asm__ ("r5"); \
  3035. - register unsigned long __sc_6 __asm__ ("r6"); \
  3036. - register unsigned long __sc_7 __asm__ ("r7"); \
  3037. - register unsigned long __sc_8 __asm__ ("r8"); \
  3038. - \
  3039. - __sc_3 = (unsigned long) (arg1); \
  3040. - __sc_4 = (unsigned long) (arg2); \
  3041. - __sc_5 = (unsigned long) (arg3); \
  3042. - __sc_6 = (unsigned long) (arg4); \
  3043. - __sc_7 = (unsigned long) (arg5); \
  3044. - __sc_8 = (unsigned long) (arg6); \
  3045. - __sc_0 = __NR_##name; \
  3046. - __asm__ __volatile__ \
  3047. - ("sc \n\t" \
  3048. - "mfcr %1 " \
  3049. - : "=&r" (__sc_3), "=&r" (__sc_0) \
  3050. - : "0" (__sc_3), "1" (__sc_0), \
  3051. - "r" (__sc_4), \
  3052. - "r" (__sc_5), \
  3053. - "r" (__sc_6), \
  3054. - "r" (__sc_7), \
  3055. - "r" (__sc_8) \
  3056. - : "r9", "r10", "r11", "r12" ); \
  3057. - __sc_ret = __sc_3; \
  3058. - __sc_err = __sc_0; \
  3059. - } \
  3060. - __syscall_return (type); \
  3061. -}
  3062. -
  3063. +#define __UCLIBC_MMAP_HAS_6_ARGS__
  3064. +#include "sys/syscall.h"
  3065. +extern int _dl_errno;
  3066. +#undef __set_errno
  3067. +#define __set_errno(X) {(_dl_errno) = (X);}
  3068. diff -urN uClibc-0.9.28.orig/ldso/ldso/powerpc/dl-sysdep.h uClibc-0.9.28/ldso/ldso/powerpc/dl-sysdep.h
  3069. --- uClibc-0.9.28.orig/ldso/ldso/powerpc/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  3070. +++ uClibc-0.9.28/ldso/ldso/powerpc/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  3071. @@ -67,9 +67,6 @@
  3072. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  3073. void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
  3074. -
  3075. -#define do_rem(result, n, base) ((result) = (n) % (base))
  3076. -
  3077. /* 4096 bytes alignment */
  3078. #define PAGE_ALIGN 0xfffff000
  3079. #define ADDR_ALIGN 0xfff
  3080. diff -urN uClibc-0.9.28.orig/ldso/ldso/powerpc/elfinterp.c uClibc-0.9.28/ldso/ldso/powerpc/elfinterp.c
  3081. --- uClibc-0.9.28.orig/ldso/ldso/powerpc/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  3082. +++ uClibc-0.9.28/ldso/ldso/powerpc/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  3083. @@ -29,6 +29,8 @@
  3084. * SUCH DAMAGE.
  3085. */
  3086. +#include "ldso.h"
  3087. +
  3088. extern int _dl_linux_resolve(void);
  3089. void _dl_init_got(unsigned long *plt,struct elf_resolve *tpnt)
  3090. @@ -138,7 +140,7 @@
  3091. finaladdr = (Elf32_Addr) _dl_find_hash(symname,
  3092. tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
  3093. if (unlikely(!finaladdr)) {
  3094. - _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
  3095. + _dl_dprintf(2, "%s: can't resolve symbol '%s' in lib '%s'.\n", _dl_progname, symname, tpnt->libname);
  3096. _dl_exit(1);
  3097. };
  3098. finaladdr += this_reloc->r_addend;
  3099. @@ -379,15 +381,15 @@
  3100. {
  3101. int reloc_type = ELF32_R_TYPE(rpnt->r_info);
  3102. #if defined (__SUPPORT_LD_DEBUG__)
  3103. - _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
  3104. + _dl_dprintf(2, "can't handle reloc type '%s' in lib '%s'\n", _dl_reltypes(reloc_type), tpnt->libname);
  3105. #else
  3106. - _dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
  3107. + _dl_dprintf(2, "can't handle reloc type %x in lib '%s'\n", reloc_type, tpnt->libname);
  3108. #endif
  3109. - _dl_exit(-res);
  3110. + return res;
  3111. }
  3112. if (unlikely(res >0))
  3113. {
  3114. - _dl_dprintf(2, "can't resolve symbol\n");
  3115. + _dl_dprintf(2, "can't resolve symbol in lib '%s'.\n", tpnt->libname);
  3116. return res;
  3117. }
  3118. }
  3119. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh/dl-startup.h uClibc-0.9.28/ldso/ldso/sh/dl-startup.h
  3120. --- uClibc-0.9.28.orig/ldso/ldso/sh/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  3121. +++ uClibc-0.9.28/ldso/ldso/sh/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  3122. @@ -55,11 +55,3 @@
  3123. default: \
  3124. _dl_exit(1); \
  3125. }
  3126. -
  3127. -
  3128. -/*
  3129. - * Transfer control to the user's application, once the dynamic loader
  3130. - * is done. This routine has to exit the current function, then
  3131. - * call the _dl_elf_main function.
  3132. - */
  3133. -#define START() return _dl_elf_main;
  3134. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh/dl-syscalls.h uClibc-0.9.28/ldso/ldso/sh/dl-syscalls.h
  3135. --- uClibc-0.9.28.orig/ldso/ldso/sh/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  3136. +++ uClibc-0.9.28/ldso/ldso/sh/dl-syscalls.h 2006-05-02 13:39:28.000000000 -0600
  3137. @@ -1,7 +1,8 @@
  3138. /* We can't use the real errno in ldso, since it has not yet
  3139. * been dynamicly linked in yet. */
  3140. +#define __UCLIBC_MMAP_HAS_6_ARGS__
  3141. +
  3142. +#include "sys/syscall.h"
  3143. extern int _dl_errno;
  3144. +#undef __set_errno
  3145. #define __set_errno(X) {(_dl_errno) = (X);}
  3146. -#include "sys/syscall.h"
  3147. -
  3148. -#define MMAP_HAS_6_ARGS
  3149. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh/dl-sysdep.h uClibc-0.9.28/ldso/ldso/sh/dl-sysdep.h
  3150. --- uClibc-0.9.28.orig/ldso/ldso/sh/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  3151. +++ uClibc-0.9.28/ldso/ldso/sh/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  3152. @@ -25,7 +25,7 @@
  3153. struct elf_resolve;
  3154. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  3155. -static __inline__ unsigned int
  3156. +static inline unsigned int
  3157. _dl_urem(unsigned int n, unsigned int base)
  3158. {
  3159. int res;
  3160. @@ -104,7 +104,7 @@
  3161. elf_machine_dynamic (void)
  3162. {
  3163. register Elf32_Addr *got;
  3164. - asm ("mov r12,%0" :"=r" (got));
  3165. + __asm__ ("mov r12,%0" :"=r" (got));
  3166. return *got;
  3167. }
  3168. @@ -113,7 +113,7 @@
  3169. elf_machine_load_address (void)
  3170. {
  3171. Elf32_Addr addr;
  3172. - asm ("mov.l 1f,r0\n\
  3173. + __asm__ ("mov.l 1f,r0\n\
  3174. mov.l 3f,r2\n\
  3175. add r12,r2\n\
  3176. mov.l @(r0,r12),r0\n\
  3177. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh/elfinterp.c uClibc-0.9.28/ldso/ldso/sh/elfinterp.c
  3178. --- uClibc-0.9.28.orig/ldso/ldso/sh/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  3179. +++ uClibc-0.9.28/ldso/ldso/sh/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  3180. @@ -39,6 +39,8 @@
  3181. a more than adequate job of explaining everything required to get this
  3182. working. */
  3183. +#include "ldso.h"
  3184. +
  3185. extern int _dl_linux_resolve(void);
  3186. unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
  3187. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh64/dl-startup.h uClibc-0.9.28/ldso/ldso/sh64/dl-startup.h
  3188. --- uClibc-0.9.28.orig/ldso/ldso/sh64/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  3189. +++ uClibc-0.9.28/ldso/ldso/sh64/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  3190. @@ -115,12 +115,3 @@
  3191. default: \
  3192. _dl_exit(1); \
  3193. }
  3194. -
  3195. -/*
  3196. - * Transfer control to the user's application, once the dynamic loader
  3197. - * is done. This routine has to exit the current function, then
  3198. - * call the _dl_elf_main function.
  3199. - */
  3200. -
  3201. -#define START() return _dl_elf_main;
  3202. -
  3203. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh64/dl-syscalls.h uClibc-0.9.28/ldso/ldso/sh64/dl-syscalls.h
  3204. --- uClibc-0.9.28.orig/ldso/ldso/sh64/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  3205. +++ uClibc-0.9.28/ldso/ldso/sh64/dl-syscalls.h 2006-04-28 00:14:35.000000000 -0600
  3206. @@ -1,8 +1,9 @@
  3207. /* We can't use the real errno in ldso, since it has not yet
  3208. * been dynamicly linked in yet. */
  3209. +#include "sys/syscall.h"
  3210. extern int _dl_errno;
  3211. +#undef __set_errno
  3212. #define __set_errno(X) {(_dl_errno) = (X);}
  3213. -#include "sys/syscall.h"
  3214. #undef __syscall_return
  3215. #define __syscall_return(type, res) \
  3216. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh64/dl-sysdep.h uClibc-0.9.28/ldso/ldso/sh64/dl-sysdep.h
  3217. --- uClibc-0.9.28.orig/ldso/ldso/sh64/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  3218. +++ uClibc-0.9.28/ldso/ldso/sh64/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  3219. @@ -25,8 +25,6 @@
  3220. struct elf_resolve;
  3221. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  3222. -#define do_rem(result, n, base) ((result) = (n) % (base))
  3223. -
  3224. /* 4096 bytes alignment */
  3225. #define PAGE_ALIGN 0xfffff000
  3226. #define ADDR_ALIGN 0xfff
  3227. diff -urN uClibc-0.9.28.orig/ldso/ldso/sh64/elfinterp.c uClibc-0.9.28/ldso/ldso/sh64/elfinterp.c
  3228. --- uClibc-0.9.28.orig/ldso/ldso/sh64/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  3229. +++ uClibc-0.9.28/ldso/ldso/sh64/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  3230. @@ -41,6 +41,8 @@
  3231. a more than adequate job of explaining everything required to get this
  3232. working. */
  3233. +#include "ldso.h"
  3234. +
  3235. extern int _dl_linux_resolve(void);
  3236. unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
  3237. diff -urN uClibc-0.9.28.orig/ldso/ldso/sparc/dl-startup.h uClibc-0.9.28/ldso/ldso/sparc/dl-startup.h
  3238. --- uClibc-0.9.28.orig/ldso/ldso/sparc/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  3239. +++ uClibc-0.9.28/ldso/ldso/sparc/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  3240. @@ -3,15 +3,46 @@
  3241. * needed for this architecture. See arm/boot1_arch.h for an example of what
  3242. * can be done.
  3243. */
  3244. -asm(
  3245. - " .text\n"
  3246. - " .global _start\n"
  3247. - " .type _start,%function\n"
  3248. - "_start:\n"
  3249. - " .set _start,_dl_start\n"
  3250. - " .size _start,.-_start\n"
  3251. - " .previous\n"
  3252. -);
  3253. +
  3254. +asm ("\
  3255. + .text\n\
  3256. + .global _start\n\
  3257. + .type _start,%function\n\
  3258. + .align 32\n\
  3259. +_start:\n\
  3260. + /* Allocate space for functions to drop their arguments. */\n\
  3261. + sub %sp, 6*4, %sp\n\
  3262. + /* Pass pointer to argument block to _dl_start. */\n\
  3263. + call _dl_start\n\
  3264. + add %sp, 22*4, %o0\n\
  3265. + /* FALTHRU */\n\
  3266. + .globl _dl_start_user\n\
  3267. + .type _dl_start_user, @function\n\
  3268. +_dl_start_user:\n\
  3269. + /* Load the PIC register. */\n\
  3270. +1: call 2f\n\
  3271. + sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n\
  3272. +2: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7\n\
  3273. + add %l7, %o7, %l7\n\
  3274. + /* Save the user entry point address in %l0 */\n\
  3275. + mov %o0, %l0\n\
  3276. + /* See if we were run as a command with the executable file name as an\n\
  3277. + extra leading argument. If so, adjust the contents of the stack. */\n\
  3278. + sethi %hi(_dl_skip_args), %g2\n\
  3279. + or %g2, %lo(_dl_skip_args), %g2\n\
  3280. + ld [%l7+%g2], %i0\n\
  3281. + ld [%i0], %i0\n\
  3282. + tst %i0\n\
  3283. + /* Pass our finalizer function to the user in %g1. */\n\
  3284. + sethi %hi(_dl_fini), %g1\n\
  3285. + or %g1, %lo(_dl_fini), %g1\n\
  3286. + ld [%l7+%g1], %g1\n\
  3287. + /* Jump to the user's entry point and deallocate the extra stack we got. */\n\
  3288. + jmp %l0\n\
  3289. + add %sp, 6*4, %sp\n\
  3290. + .size _dl_start_user, . - _dl_start_user\n\
  3291. + .previous\n\
  3292. +");
  3293. /*
  3294. * Get a pointer to the argv array. On many platforms this can be just
  3295. @@ -19,17 +50,15 @@
  3296. * do something a little more subtle here. We assume that argc is stored
  3297. * at the word just below the argvp that we return here.
  3298. */
  3299. -#define GET_ARGV(ARGVP, ARGS) __asm__("\tadd %%fp,68,%0\n" : "=r" (ARGVP));
  3300. +#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long *) ARGS) + 1)
  3301. /*
  3302. * Here is a macro to perform a relocation. This is only used when
  3303. * bootstrapping the dynamic loader.
  3304. */
  3305. #define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
  3306. - switch(ELF32_R_TYPE((RELP)->r_info)) { \
  3307. +switch(ELF_R_TYPE((RELP)->r_info)) { \
  3308. case R_SPARC_32: \
  3309. - *REL = SYMBOL + (RELP)->r_addend; \
  3310. - break; \
  3311. case R_SPARC_GLOB_DAT: \
  3312. *REL = SYMBOL + (RELP)->r_addend; \
  3313. break; \
  3314. @@ -38,7 +67,6 @@
  3315. REL[2] = 0x81c06000 | (SYMBOL & 0x3ff); \
  3316. break; \
  3317. case R_SPARC_NONE: \
  3318. - break; \
  3319. case R_SPARC_WDISP30: \
  3320. break; \
  3321. case R_SPARC_RELATIVE: \
  3322. @@ -46,18 +74,4 @@
  3323. break; \
  3324. default: \
  3325. _dl_exit(1); \
  3326. - }
  3327. -
  3328. -/*
  3329. - * Transfer control to the user's application, once the dynamic loader
  3330. - * is done. The crt calls atexit with $g1 if not null, so we need to
  3331. - * ensure that it contains NULL.
  3332. - */
  3333. -
  3334. -#define START() \
  3335. - __asm__ volatile ( \
  3336. - "add %%g0,%%g0,%%g1\n\t" \
  3337. - "jmpl %0, %%o7\n\t" \
  3338. - "restore %%g0,%%g0,%%g0\n\t" \
  3339. - : /*"=r" (status) */ : \
  3340. - "r" (_dl_elf_main): "g1", "o0", "o1")
  3341. +}
  3342. diff -urN uClibc-0.9.28.orig/ldso/ldso/sparc/dl-syscalls.h uClibc-0.9.28/ldso/ldso/sparc/dl-syscalls.h
  3343. --- uClibc-0.9.28.orig/ldso/ldso/sparc/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  3344. +++ uClibc-0.9.28/ldso/ldso/sparc/dl-syscalls.h 2006-05-02 13:39:21.000000000 -0600
  3345. @@ -1,187 +1,8 @@
  3346. -/*
  3347. - * This file contains the system call macros and syscall
  3348. - * numbers used by the shared library loader.
  3349. - *
  3350. - * NOTE: This should be integrated/moved to
  3351. - * sysdeps/linux/sparc/bits/syscalls.h at some point ...
  3352. - */
  3353. -
  3354. -#define MMAP_HAS_6_ARGS
  3355. -
  3356. -#define __NR_exit 1
  3357. -#define __NR_read 3
  3358. -#define __NR_write 4
  3359. -#define __NR_open 5
  3360. -#define __NR_close 6
  3361. -#define __NR_getpid 20
  3362. -#define __NR_getuid 24
  3363. -#define __NR_getgid 47
  3364. -#define __NR_geteuid 49
  3365. -#define __NR_getegid 50
  3366. -#define __NR_readlink 58
  3367. -#define __NR_mmap 71
  3368. -#define __NR_munmap 73
  3369. -#define __NR_stat 38
  3370. -#define __NR_mprotect 74
  3371. -
  3372. /* We can't use the real errno in ldso, since it has not yet
  3373. * been dynamicly linked in yet. */
  3374. +#define __UCLIBC_MMAP_HAS_6_ARGS__
  3375. +
  3376. +#include "sys/syscall.h"
  3377. extern int _dl_errno;
  3378. +#undef __set_errno
  3379. #define __set_errno(X) {(_dl_errno) = (X);}
  3380. -
  3381. -/* Here are the macros which define how this platform makes
  3382. - * system calls. This particular variant does _not_ set
  3383. - * errno (note how _dl_errno is used in __syscall_return) since
  3384. - * these will get called before the errno symbol is dynamicly
  3385. - * linked. */
  3386. -
  3387. -#define __syscall_return(type, res) \
  3388. -do { \
  3389. - if (res < -255 || res >= 0) \
  3390. - return (type) res; \
  3391. - __set_errno(-res); \
  3392. - res = -1; \
  3393. - return (type) res; \
  3394. -} while (0)
  3395. -
  3396. -#define _syscall0(type,name) \
  3397. -type name(void) \
  3398. -{ \
  3399. - long __res; \
  3400. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3401. - __asm__ __volatile__ ( \
  3402. - "t 0x10\n\t" \
  3403. - "bcc 1f\n\t" \
  3404. - "mov %%o0, %0\n\t" \
  3405. - "sub %%g0, %%o0, %0\n\t" \
  3406. - "1:\n\t" \
  3407. - : "=r" (__res)\
  3408. - : "r" (__g1) \
  3409. - : "o0", "cc"); \
  3410. - __syscall_return(type, __res); \
  3411. -}
  3412. -
  3413. -#define _syscall1(type,name,type1,arg1) \
  3414. -type name(type1 arg1) \
  3415. -{ \
  3416. - long __res; \
  3417. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3418. - register long __o0 __asm__ ("o0") = (long)(arg1); \
  3419. - __asm__ __volatile__ ( \
  3420. - "t 0x10\n\t" \
  3421. - "bcc 1f\n\t" \
  3422. - "mov %%o0, %0\n\t" \
  3423. - "sub %%g0, %%o0, %0\n\t" \
  3424. - "1:\n\t" \
  3425. - : "=r" (__res), "=&r" (__o0) \
  3426. - : "1" (__o0), "r" (__g1) \
  3427. - : "cc"); \
  3428. - __syscall_return(type, __res); \
  3429. -}
  3430. -
  3431. -#define _syscall2(type,name,type1,arg1,type2,arg2) \
  3432. -type name(type1 arg1,type2 arg2) \
  3433. -{ \
  3434. - long __res; \
  3435. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3436. - register long __o0 __asm__ ("o0") = (long)(arg1); \
  3437. - register long __o1 __asm__ ("o1") = (long)(arg2); \
  3438. - __asm__ __volatile__ ( \
  3439. - "t 0x10\n\t" \
  3440. - "bcc 1f\n\t" \
  3441. - "mov %%o0, %0\n\t" \
  3442. - "sub %%g0, %%o0, %0\n\t" \
  3443. - "1:\n\t" \
  3444. - : "=r" (__res), "=&r" (__o0) \
  3445. - : "1" (__o0), "r" (__o1), "r" (__g1) \
  3446. - : "cc"); \
  3447. - __syscall_return(type, __res); \
  3448. -}
  3449. -
  3450. -#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  3451. -type name(type1 arg1,type2 arg2,type3 arg3) \
  3452. -{ \
  3453. - long __res; \
  3454. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3455. - register long __o0 __asm__ ("o0") = (long)(arg1); \
  3456. - register long __o1 __asm__ ("o1") = (long)(arg2); \
  3457. - register long __o2 __asm__ ("o2") = (long)(arg3); \
  3458. - __asm__ __volatile__ ( \
  3459. - "t 0x10\n\t" \
  3460. - "bcc 1f\n\t" \
  3461. - "mov %%o0, %0\n\t" \
  3462. - "sub %%g0, %%o0, %0\n\t" \
  3463. - "1:\n\t" \
  3464. - : "=r" (__res), "=&r" (__o0) \
  3465. - : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
  3466. - : "cc"); \
  3467. - __syscall_return(type, __res); \
  3468. -}
  3469. -
  3470. -#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  3471. -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  3472. -{ \
  3473. - long __res; \
  3474. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3475. - register long __o0 __asm__ ("o0") = (long)(arg1); \
  3476. - register long __o1 __asm__ ("o1") = (long)(arg2); \
  3477. - register long __o2 __asm__ ("o2") = (long)(arg3); \
  3478. - register long __o3 __asm__ ("o3") = (long)(arg4); \
  3479. - __asm__ __volatile__ ( \
  3480. - "t 0x10\n\t" \
  3481. - "bcc 1f\n\t" \
  3482. - "mov %%o0, %0\n\t" \
  3483. - "sub %%g0, %%o0, %0\n\t" \
  3484. - "1:\n\t" \
  3485. - : "=r" (__res), "=&r" (__o0) \
  3486. - : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
  3487. - : "cc"); \
  3488. - __syscall_return(type, __res); \
  3489. -}
  3490. -
  3491. -#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  3492. - type5,arg5) \
  3493. -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
  3494. -{ \
  3495. - long __res; \
  3496. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3497. - register long __o0 __asm__ ("o0") = (long)(arg1); \
  3498. - register long __o1 __asm__ ("o1") = (long)(arg2); \
  3499. - register long __o2 __asm__ ("o2") = (long)(arg3); \
  3500. - register long __o3 __asm__ ("o3") = (long)(arg4); \
  3501. - register long __o4 __asm__ ("o4") = (long)(arg5); \
  3502. - __asm__ __volatile__ ( \
  3503. - "t 0x10\n\t" \
  3504. - "bcc 1f\n\t" \
  3505. - "mov %%o0, %0\n\t" \
  3506. - "sub %%g0, %%o0, %0\n\t" \
  3507. - "1:\n\t" \
  3508. - : "=r" (__res), "=&r" (__o0) \
  3509. - : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
  3510. - : "cc"); \
  3511. - __syscall_return(type, __res); \
  3512. -}
  3513. -
  3514. -#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  3515. - type5,arg5,type6,arg6) \
  3516. -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
  3517. -{ \
  3518. - long __res; \
  3519. - register long __g1 __asm__ ("g1") = __NR_##name; \
  3520. - register long __o0 __asm__ ("o0") = (long)(arg1); \
  3521. - register long __o1 __asm__ ("o1") = (long)(arg2); \
  3522. - register long __o2 __asm__ ("o2") = (long)(arg3); \
  3523. - register long __o3 __asm__ ("o3") = (long)(arg4); \
  3524. - register long __o4 __asm__ ("o4") = (long)(arg5); \
  3525. - register long __o5 __asm__ ("o5") = (long)(arg6); \
  3526. - __asm__ __volatile__ ( \
  3527. - "t 0x10\n\t" \
  3528. - "bcc 1f\n\t" \
  3529. - "mov %%o0, %0\n\t" \
  3530. - "sub %%g0, %%o0, %0\n\t" \
  3531. - "1:\n\t" \
  3532. - : "=r" (__res), "=&r" (__o0) \
  3533. - : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__o5), "r" (__g1) \
  3534. - : "cc"); \
  3535. - __syscall_return(type, __res); \
  3536. -}
  3537. diff -urN uClibc-0.9.28.orig/ldso/ldso/sparc/dl-sysdep.h uClibc-0.9.28/ldso/ldso/sparc/dl-sysdep.h
  3538. --- uClibc-0.9.28.orig/ldso/ldso/sparc/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  3539. +++ uClibc-0.9.28/ldso/ldso/sparc/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  3540. @@ -1,9 +1,9 @@
  3541. -
  3542. +/* vi: set sw=4 ts=4: */
  3543. /*
  3544. * Various assmbly language/system dependent hacks that are required
  3545. * so that we can minimize the amount of platform specific code.
  3546. + * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  3547. */
  3548. -#define LINUXBIN
  3549. /* Define this if the system uses RELOCA. */
  3550. #define ELF_USES_RELOCA
  3551. @@ -31,19 +31,14 @@
  3552. #undef MAGIC2
  3553. /* Used for error messages */
  3554. -#define ELF_TARGET "Sparc"
  3555. +#define ELF_TARGET "sparc"
  3556. -#ifndef COMPILE_ASM
  3557. -extern unsigned int _dl_linux_resolver(unsigned int reloc_entry,
  3558. - unsigned int * i);
  3559. -#endif
  3560. +struct elf_resolve;
  3561. +unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  3562. /*
  3563. * Define this if you want a dynamic loader that works on Solaris.
  3564. */
  3565. -#ifndef __linux__
  3566. -#define SOLARIS_COMPATIBLE
  3567. -#endif
  3568. #ifndef COMPILE_ASM
  3569. /* Cheap modulo implementation, taken from arm/ld_sysdep.h. */
  3570. @@ -87,13 +82,6 @@
  3571. #define do_rem(result, n, base) ((result) = sparc_mod(n, base))
  3572. #endif
  3573. -/*
  3574. - * dbx wants the binder to have a specific name. Mustn't disappoint it.
  3575. - */
  3576. -#ifdef SOLARIS_COMPATIBLE
  3577. -#define _dl_linux_resolve _elf_rtbndr
  3578. -#endif
  3579. -
  3580. /* 4096 bytes alignment */
  3581. /* ...but 8192 is required for mmap() on sparc64 kernel */
  3582. #define PAGE_ALIGN 0xffffe000
  3583. @@ -160,7 +148,7 @@
  3584. elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
  3585. Elf32_Word relative_count)
  3586. {
  3587. - Elf32_Rela * rpnt = (void *)rel_addr;
  3588. + Elf32_Rela * rpnt = (void *)rel_addr;
  3589. --rpnt;
  3590. do {
  3591. Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
  3592. diff -urN uClibc-0.9.28.orig/ldso/ldso/sparc/elfinterp.c uClibc-0.9.28/ldso/ldso/sparc/elfinterp.c
  3593. --- uClibc-0.9.28.orig/ldso/ldso/sparc/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  3594. +++ uClibc-0.9.28/ldso/ldso/sparc/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  3595. @@ -33,236 +33,340 @@
  3596. an ELF sharable library or a linux style of shared library. */
  3597. /* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
  3598. - I ever taken any courses on internals. This program was developed using
  3599. - information available through the book "UNIX SYSTEM V RELEASE 4,
  3600. - Programmers guide: Ansi C and Programming Support Tools", which did
  3601. - a more than adequate job of explaining everything required to get this
  3602. - working. */
  3603. + I ever taken any courses on internals. This program was developed using
  3604. + information available through the book "UNIX SYSTEM V RELEASE 4,
  3605. + Programmers guide: Ansi C and Programming Support Tools", which did
  3606. + a more than adequate job of explaining everything required to get this
  3607. + working. */
  3608. +
  3609. +/* Some SPARC opcodes we need to use for self-modifying code. */
  3610. +#define OPCODE_NOP 0x01000000 /* nop */
  3611. +#define OPCODE_CALL 0x40000000 /* call ?; add PC-rel word address */
  3612. +#define OPCODE_SETHI_G1 0x03000000 /* sethi ?, %g1; add value>>10 */
  3613. +#define OPCODE_JMP_G1 0x81c06000 /* jmp %g1+?; add lo 10 bits of value */
  3614. +#define OPCODE_SAVE_SP 0x9de3bfa8 /* save %sp, -(16+6)*4, %sp */
  3615. +#define OPCODE_BA 0x30800000 /* b,a ?; add PC-rel word address */
  3616. extern int _dl_linux_resolve(void);
  3617. -unsigned int _dl_linux_resolver(unsigned int reloc_entry, unsigned int * plt)
  3618. +unsigned long
  3619. +_dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry)
  3620. {
  3621. - int reloc_type;
  3622. - Elf32_Rela * this_reloc;
  3623. - char * strtab;
  3624. - Elf32_Sym * symtab;
  3625. - Elf32_Rela * rel_addr;
  3626. - struct elf_resolve * tpnt;
  3627. - int symtab_index;
  3628. - char * new_addr;
  3629. - char ** got_addr;
  3630. - unsigned int instr_addr;
  3631. - tpnt = (struct elf_resolve *) plt[2];
  3632. -
  3633. - rel_addr = (Elf32_Rela *)tpnt->dynamic_info[DT_JMPREL];
  3634. -
  3635. - /*
  3636. - * Generate the correct relocation index into the .rela.plt section.
  3637. - */
  3638. - reloc_entry = (reloc_entry >> 10) - 0xc;
  3639. -
  3640. - this_reloc = (Elf32_Rela *) ((char *) rel_addr + reloc_entry);
  3641. -
  3642. - reloc_type = ELF32_R_TYPE(this_reloc->r_info);
  3643. - symtab_index = ELF32_R_SYM(this_reloc->r_info);
  3644. -
  3645. - symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
  3646. - strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  3647. -
  3648. -#ifdef __SUPPORT_LD_DEBUG__
  3649. - if (_dl_debug_symbols) {
  3650. - _dl_dprintf(2, "tpnt = %x\n", tpnt);
  3651. - _dl_dprintf(2, "reloc = %x\n", this_reloc);
  3652. - _dl_dprintf(2, "symtab = %x\n", symtab);
  3653. - _dl_dprintf(2, "strtab = %x\n", strtab);
  3654. - }
  3655. -#endif
  3656. -
  3657. -
  3658. - if (unlikely(reloc_type != R_SPARC_JMP_SLOT)) {
  3659. - _dl_dprintf(2, "%s: incorrect relocation type in jump relocations (%d)\n",
  3660. - _dl_progname, reloc_type);
  3661. - _dl_exit(30);
  3662. - };
  3663. -
  3664. - /* Address of jump instruction to fix up */
  3665. - instr_addr = ((int)this_reloc->r_offset + (int)tpnt->loadaddr);
  3666. - got_addr = (char **) instr_addr;
  3667. -
  3668. -#ifdef __SUPPORT_LD_DEBUG__
  3669. - if (_dl_debug_symbols) {
  3670. - _dl_dprintf(2, "symtab_index %x\n", symtab_index);
  3671. -
  3672. - _dl_dprintf(2, "Resolving symbol %s\n",
  3673. - strtab + symtab[symtab_index].st_name);
  3674. - }
  3675. -#endif
  3676. -
  3677. - /* Get the address of the GOT entry */
  3678. - new_addr = _dl_find_hash(strtab + symtab[symtab_index].st_name,
  3679. - tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
  3680. - if(unlikely(!new_addr)) {
  3681. - _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
  3682. - _dl_progname, strtab + symtab[symtab_index].st_name);
  3683. - _dl_exit(31);
  3684. - };
  3685. + int reloc_type;
  3686. + ELF_RELOC *this_reloc;
  3687. + char *strtab;
  3688. + ElfW(Sym) *symtab;
  3689. + int symtab_index;
  3690. + char *rel_addr;
  3691. + char *new_addr;
  3692. + char **got_addr;
  3693. + ElfW(Addr) instr_addr;
  3694. + char *symname;
  3695. +
  3696. + rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
  3697. + /*
  3698. + * Generate the correct relocation index into the .rela.plt section.
  3699. + */
  3700. + reloc_entry = (reloc_entry >> 10) - 0xc;
  3701. +
  3702. + this_reloc = (ELF_RELOC *)(rel_addr + reloc_entry);
  3703. + reloc_type = ELF_R_TYPE(this_reloc->r_info);
  3704. + symtab_index = ELF_R_SYM(this_reloc->r_info);
  3705. +
  3706. + symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
  3707. + strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  3708. + symname = strtab + symtab[symtab_index].st_name;
  3709. +
  3710. + if (unlikely(reloc_type != R_SPARC_JMP_SLOT)) {
  3711. + _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
  3712. + _dl_progname);
  3713. + _dl_exit(1);
  3714. + }
  3715. +
  3716. + /* Address of the jump instruction to fix up. */
  3717. + instr_addr = (this_reloc->r_offset + tpnt->loadaddr);
  3718. + got_addr = (char **)instr_addr;
  3719. +
  3720. + /* Get the address of the GOT entry */
  3721. + new_addr = _dl_find_hash(symname, tpnt->symbol_scope, tpnt, ELF_RTYPE_CLASS_PLT);
  3722. + if (unlikely(!new_addr)) {
  3723. + _dl_dprintf(2, "%s: Can't resolve symbol '%s'\n", _dl_progname, symname);
  3724. + _dl_exit(1);
  3725. + }
  3726. #if defined (__SUPPORT_LD_DEBUG__)
  3727. - if ((unsigned long) got_addr < 0x40000000)
  3728. - {
  3729. - if (_dl_debug_bindings)
  3730. - {
  3731. - _dl_dprintf(_dl_debug_file, "\nresolve function: %s",
  3732. - strtab + symtab[symtab_index].st_name);
  3733. - if(_dl_debug_detail) _dl_dprintf(_dl_debug_file,
  3734. - "\tpatch %x ==> %x @ %x", *got_addr, new_addr, got_addr);
  3735. + if ((unsigned long)got_addr < 0x40000000) {
  3736. + if (_dl_debug_bindings) {
  3737. + _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
  3738. + if (_dl_debug_detail)
  3739. + _dl_dprintf(_dl_debug_file,
  3740. + "\tpatched: %x ==> %x @ %x\n",
  3741. + *got_addr, new_addr, got_addr);
  3742. }
  3743. }
  3744. - if (!_dl_debug_nofixups) {
  3745. + if (!_dl_debug_nofixups)
  3746. +#endif
  3747. + {
  3748. got_addr[1] = (char *) (0x03000000 | (((unsigned int) new_addr >> 10) & 0x3fffff));
  3749. got_addr[2] = (char *) (0x81c06000 | ((unsigned int) new_addr & 0x3ff));
  3750. }
  3751. +
  3752. + return (unsigned long)new_addr;
  3753. +}
  3754. +
  3755. +static int
  3756. +_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
  3757. + unsigned long rel_addr, unsigned long rel_size,
  3758. + int (*reloc_fnc)(struct elf_resolve *tpnt, struct dyn_elf *scope,
  3759. + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
  3760. +{
  3761. + unsigned int i;
  3762. + char *strtab;
  3763. + ElfW(Sym) *symtab;
  3764. + ELF_RELOC *rpnt;
  3765. + int symtab_index;
  3766. +
  3767. + /* Parse the relocation information. */
  3768. + rpnt = (ELF_RELOC *)rel_addr;
  3769. + rel_size /= sizeof(ELF_RELOC);
  3770. +
  3771. + symtab = (ElfW(Sym) *)tpnt->dynamic_info[DT_SYMTAB];
  3772. + strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
  3773. +
  3774. + for (i = 0; i < rel_size; i++, rpnt++) {
  3775. + int res;
  3776. +
  3777. + symtab_index = ELF_R_SYM(rpnt->r_info);
  3778. +
  3779. + debug_sym(symtab, strtab, symtab_index);
  3780. + debug_reloc(symtab, strtab, rpnt);
  3781. +
  3782. + res = reloc_fnc(tpnt, scope, rpnt, symtab, strtab);
  3783. +
  3784. + if (res == 0)
  3785. + continue;
  3786. +
  3787. + _dl_dprintf(2, "\n%s: ", _dl_progname);
  3788. +
  3789. + if (symtab_index)
  3790. + _dl_dprintf(2, "symbol '%s': ",
  3791. + strtab + symtab[symtab_index].st_name);
  3792. +
  3793. + if (unlikely(res < 0)) {
  3794. + int reloc_type = ELF_R_TYPE(rpnt->r_info);
  3795. +
  3796. + _dl_dprintf(2, "can't handle reloc type "
  3797. +#if defined (__SUPPORT_LD_DEBUG__)
  3798. + "%s\n", _dl_reltypes(reloc_type));
  3799. #else
  3800. - got_addr[1] = (char *) (0x03000000 | (((unsigned int) new_addr >> 10) & 0x3fffff));
  3801. - got_addr[2] = (char *) (0x81c06000 | ((unsigned int) new_addr & 0x3ff));
  3802. + "%x\n", reloc_type);
  3803. #endif
  3804. + _dl_exit(-res);
  3805. + } else if (unlikely(res > 0)) {
  3806. + _dl_dprintf(2, "can't resolve symbol\n");
  3807. + return res;
  3808. + }
  3809. + }
  3810. +
  3811. + return 0;
  3812. +}
  3813. - _dl_dprintf(2, "Address = %x\n",new_addr);
  3814. - _dl_exit(32);
  3815. +static int
  3816. +_dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
  3817. + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
  3818. +{
  3819. + int reloc_type;
  3820. + int symtab_index;
  3821. + char *symname;
  3822. + ElfW(Sym) *sym;
  3823. + ElfW(Addr) *reloc_addr;
  3824. + ElfW(Addr) symbol_addr;
  3825. +#if defined (__SUPPORT_LD_DEBUG__)
  3826. + ElfW(Addr) old_val;
  3827. +#endif
  3828. +
  3829. + reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
  3830. + reloc_type = ELF_R_TYPE(rpnt->r_info);
  3831. + symtab_index = ELF_R_SYM(rpnt->r_info);
  3832. + sym = &symtab[symtab_index];
  3833. + symbol_addr = 0;
  3834. + symname = strtab + sym->st_name;
  3835. +
  3836. + if (symtab_index) {
  3837. + symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
  3838. + elf_machine_type_class(reloc_type));
  3839. + /*
  3840. + * We want to allow undefined references to weak symbols - this
  3841. + * might have been intentional. We should not be linking local
  3842. + * symbols here, so all bases should be covered.
  3843. + */
  3844. + if (unlikely(!symbol_addr && ELF_ST_BIND(sym->st_info) != STB_WEAK)) {
  3845. + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
  3846. + _dl_exit(1);
  3847. + }
  3848. + }
  3849. +
  3850. +#if defined (__SUPPORT_LD_DEBUG__)
  3851. + old_val = *reloc_addr;
  3852. +#endif
  3853. - return (unsigned int) new_addr;
  3854. + symbol_addr += rpnt->r_addend; /* Assume copy relocs have zero addend. */
  3855. +
  3856. + switch (reloc_type) {
  3857. + case R_SPARC_NONE:
  3858. + break;
  3859. +
  3860. +#if 0 /* these dont really seem to be useful */
  3861. + case R_SPARC_8:
  3862. + *(char *) reloc_addr = symbol_addr;
  3863. + break;
  3864. + case R_SPARC_16:
  3865. + *(short *) reloc_addr = symbol_addr;
  3866. + break;
  3867. + case R_SPARC_DISP8:
  3868. + *(char *) reloc_addr = (symbol_addr) - (Elf32_Addr) reloc_addr;
  3869. + break;
  3870. + case R_SPARC_DISP16:
  3871. + *(short *) reloc_addr = (symbol_addr) - (Elf32_Addr) reloc_addr;
  3872. + break;
  3873. +#endif
  3874. +
  3875. + case R_SPARC_DISP32:
  3876. + *reloc_addr = symbol_addr - (unsigned int) reloc_addr;
  3877. + break;
  3878. +
  3879. + case R_SPARC_LO10:
  3880. + if (!symbol_addr)
  3881. + symbol_addr = tpnt->loadaddr + rpnt->r_addend;
  3882. + else
  3883. + symbol_addr += rpnt->r_addend;
  3884. + *reloc_addr = (*reloc_addr & ~0x3ff)|(symbol_addr & 0x3ff);
  3885. + break;
  3886. +
  3887. + case R_SPARC_GLOB_DAT:
  3888. + case R_SPARC_32:
  3889. + *reloc_addr = symbol_addr;
  3890. + break;
  3891. +
  3892. + case R_SPARC_JMP_SLOT:
  3893. +/*
  3894. +value = symbol_addr;
  3895. +value += reloc->r_addend;
  3896. +disp = value - reloc_addr;
  3897. +reloc_addr[1] = OPCODE_JMP_G1 | (value & 0x3ff);
  3898. +reloc_addr[0] = OPCODE_SETHI_G1 | (value >> 10);
  3899. + reloc_addr[1] = OPCODE_JMP_G1 | ((symbol_addr-(Elf32_Addr)reloc_addr) & 0x3ff);
  3900. + reloc_addr[0] = OPCODE_SETHI_G1 | ((symbol_addr-(Elf32_Addr)reloc_addr) >> 10);
  3901. +*/
  3902. + reloc_addr[1] = 0x03000000 | ((symbol_addr >> 10) & 0x3fffff);
  3903. + reloc_addr[2] = 0x81c06000 | (symbol_addr & 0x3ff);
  3904. + break;
  3905. +
  3906. + case R_SPARC_RELATIVE:
  3907. + *reloc_addr += tpnt->loadaddr + rpnt->r_addend;
  3908. + break;
  3909. +
  3910. + case R_SPARC_WDISP30:
  3911. + *reloc_addr = (*reloc_addr & 0xc0000000)|
  3912. + ((symbol_addr - (unsigned int) reloc_addr) >> 2);
  3913. + break;
  3914. +
  3915. + case R_SPARC_HI22:
  3916. + if (!symbol_addr)
  3917. + symbol_addr = tpnt->loadaddr + rpnt->r_addend;
  3918. + else
  3919. + symbol_addr += rpnt->r_addend;
  3920. + *reloc_addr = (*reloc_addr & 0xffc00000) | (symbol_addr >> 10);
  3921. + break;
  3922. +
  3923. + case R_SPARC_COPY:
  3924. + if (symbol_addr) {
  3925. +#if defined (__SUPPORT_LD_DEBUG__)
  3926. + if (_dl_debug_move)
  3927. + _dl_dprintf(_dl_debug_file,
  3928. + "\t%s move %d bytes from %x to %x\n",
  3929. + symname, sym->st_size,
  3930. + symbol_addr, reloc_addr);
  3931. +#endif
  3932. +
  3933. + _dl_memcpy((char *)reloc_addr,
  3934. + (char *)symbol_addr,
  3935. + sym->st_size);
  3936. + } else
  3937. + _dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
  3938. + break;
  3939. + default:
  3940. + return -1; /* Calls _dl_exit(1). */
  3941. + }
  3942. +
  3943. +#if defined (__SUPPORT_LD_DEBUG__)
  3944. + if (_dl_debug_reloc && _dl_debug_detail)
  3945. + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
  3946. + old_val, *reloc_addr, reloc_addr);
  3947. +#endif
  3948. +
  3949. + return 0;
  3950. +}
  3951. +
  3952. +#undef __SPARC_LAZY_RELOC_WORKS
  3953. +#ifdef __SPARC_LAZY_RELOC_WORKS
  3954. +static int
  3955. +_dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
  3956. + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
  3957. +{
  3958. + int reloc_type;
  3959. + int symtab_index;
  3960. + ElfW(Addr) *reloc_addr;
  3961. +#if defined (__SUPPORT_LD_DEBUG__)
  3962. + ElfW(Addr) old_val;
  3963. +#endif
  3964. +
  3965. + (void)scope;
  3966. + symtab_index = ELF_R_SYM(rpnt->r_info);
  3967. + (void)strtab;
  3968. +
  3969. + reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + rpnt->r_offset);
  3970. + reloc_type = ELF_R_TYPE(rpnt->r_info);
  3971. +
  3972. +#if defined (__SUPPORT_LD_DEBUG__)
  3973. + old_val = *reloc_addr;
  3974. +#endif
  3975. +
  3976. + switch (reloc_type) {
  3977. + case R_SPARC_NONE:
  3978. + break;
  3979. + case R_SPARC_JMP_SLOT:
  3980. + break;
  3981. + default:
  3982. + _dl_exit(1);
  3983. + }
  3984. +
  3985. +#if defined (__SUPPORT_LD_DEBUG__)
  3986. + if (_dl_debug_reloc && _dl_debug_detail)
  3987. + _dl_dprintf(_dl_debug_file, "\tpatched_lazy: %x ==> %x @ %x\n",
  3988. + old_val, *reloc_addr, reloc_addr);
  3989. +#endif
  3990. +
  3991. + return 0;
  3992. }
  3993. +#endif
  3994. -void _dl_parse_lazy_relocation_information(struct dyn_elf *arg_rpnt,
  3995. - unsigned long rel_addr, unsigned long rel_size)
  3996. -{
  3997. - int i;
  3998. - char * strtab;
  3999. - int reloc_type;
  4000. - int symtab_index;
  4001. - Elf32_Sym * symtab;
  4002. - Elf32_Rela * rpnt;
  4003. - unsigned int * reloc_addr;
  4004. - struct elf_resolve * tpnt = arg_rpnt->dyn;
  4005. -
  4006. - /* Now parse the relocation information */
  4007. - rpnt = (Elf32_Rela *)rel_addr;
  4008. -
  4009. - symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
  4010. - strtab = ( char *)tpnt->dynamic_info[DT_STRTAB];
  4011. -
  4012. - for(i=0; i< rel_size; i += sizeof(Elf32_Rela), rpnt++){
  4013. - reloc_addr = (int *) (tpnt->loadaddr + (int)rpnt->r_offset);
  4014. - reloc_type = ELF32_R_TYPE(rpnt->r_info);
  4015. - symtab_index = ELF32_R_SYM(rpnt->r_info);
  4016. -
  4017. - switch(reloc_type){
  4018. - case R_SPARC_NONE:
  4019. - break;
  4020. - case R_SPARC_JMP_SLOT:
  4021. - break;
  4022. - default:
  4023. - _dl_dprintf(2, "%s: (LAZY) can't handle reloc type ", _dl_progname);
  4024. -#if defined (__SUPPORT_LD_DEBUG__)
  4025. - _dl_dprintf(2, "%s ", _dl_reltypes_tab[reloc_type]);
  4026. -#endif
  4027. - if(symtab_index) _dl_dprintf(2, "'%s'\n",
  4028. - strtab + symtab[symtab_index].st_name);
  4029. - _dl_exit(33);
  4030. - };
  4031. - };
  4032. -}
  4033. -
  4034. -int _dl_parse_relocation_information(struct dyn_elf *arg_rpnt,
  4035. - unsigned long rel_addr, unsigned long rel_size)
  4036. -{
  4037. - int i;
  4038. - char * strtab;
  4039. - int reloc_type;
  4040. - int goof = 0;
  4041. - Elf32_Sym * symtab;
  4042. - Elf32_Rela * rpnt;
  4043. - unsigned int * reloc_addr;
  4044. - unsigned int symbol_addr;
  4045. - int symtab_index;
  4046. - struct elf_resolve * tpnt = arg_rpnt->dyn;
  4047. - /* Now parse the relocation information */
  4048. -
  4049. - rpnt = (Elf32_Rela *)rel_addr;
  4050. -
  4051. - symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
  4052. - strtab = ( char *)tpnt->dynamic_info[DT_STRTAB];
  4053. -
  4054. - for(i=0; i< rel_size; i+= sizeof(Elf32_Rela), rpnt++){
  4055. - reloc_addr = (int *) (tpnt->loadaddr + (int)rpnt->r_offset);
  4056. - reloc_type = ELF32_R_TYPE(rpnt->r_info);
  4057. - symtab_index = ELF32_R_SYM(rpnt->r_info);
  4058. - symbol_addr = 0;
  4059. -
  4060. - if(symtab_index) {
  4061. -
  4062. - symbol_addr = (unsigned int)
  4063. - _dl_find_hash(strtab + symtab[symtab_index].st_name,
  4064. - tpnt->symbol_scope, tpnt, elf_machine_type_class(reloc_type));
  4065. -
  4066. - if(!symbol_addr &&
  4067. - ELF32_ST_BIND(symtab [symtab_index].st_info) != STB_WEAK) {
  4068. - _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
  4069. - _dl_progname, strtab + symtab[symtab_index].st_name);
  4070. - _dl_exit (1);
  4071. - };
  4072. - };
  4073. - switch(reloc_type){
  4074. - case R_SPARC_NONE:
  4075. - break;
  4076. - case R_SPARC_32:
  4077. - *reloc_addr = symbol_addr + rpnt->r_addend;
  4078. - break;
  4079. - case R_SPARC_DISP32:
  4080. - *reloc_addr = symbol_addr + rpnt->r_addend - (unsigned int) reloc_addr;
  4081. - break;
  4082. - case R_SPARC_GLOB_DAT:
  4083. - *reloc_addr = symbol_addr + rpnt->r_addend;
  4084. - break;
  4085. - case R_SPARC_JMP_SLOT:
  4086. - reloc_addr[1] = 0x03000000 | ((symbol_addr >> 10) & 0x3fffff);
  4087. - reloc_addr[2] = 0x81c06000 | (symbol_addr & 0x3ff);
  4088. - break;
  4089. - case R_SPARC_RELATIVE:
  4090. - *reloc_addr += (unsigned int) tpnt->loadaddr + rpnt->r_addend;
  4091. - break;
  4092. - case R_SPARC_HI22:
  4093. - if (!symbol_addr)
  4094. - symbol_addr = tpnt->loadaddr + rpnt->r_addend;
  4095. - else
  4096. - symbol_addr += rpnt->r_addend;
  4097. - *reloc_addr = (*reloc_addr & 0xffc00000)|(symbol_addr >> 10);
  4098. - break;
  4099. - case R_SPARC_LO10:
  4100. - if (!symbol_addr)
  4101. - symbol_addr = tpnt->loadaddr + rpnt->r_addend;
  4102. - else
  4103. - symbol_addr += rpnt->r_addend;
  4104. - *reloc_addr = (*reloc_addr & ~0x3ff)|(symbol_addr & 0x3ff);
  4105. - break;
  4106. - case R_SPARC_WDISP30:
  4107. - *reloc_addr = (*reloc_addr & 0xc0000000)|
  4108. - ((symbol_addr - (unsigned int) reloc_addr) >> 2);
  4109. - break;
  4110. - case R_SPARC_COPY:
  4111. - _dl_memcpy((void *) reloc_addr, (void *) symbol_addr, symtab[symtab_index].st_size);
  4112. - break;
  4113. - default:
  4114. - _dl_dprintf(2, "%s: can't handle reloc type ", _dl_progname);
  4115. -#if defined (__SUPPORT_LD_DEBUG__)
  4116. - _dl_dprintf(2, "%s ", _dl_reltypes_tab[reloc_type]);
  4117. -#endif
  4118. - if (symtab_index)
  4119. - _dl_dprintf(2, "'%s'\n", strtab + symtab[symtab_index].st_name);
  4120. - _dl_exit(34);
  4121. - };
  4122. +void
  4123. +_dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
  4124. + unsigned long rel_addr,
  4125. + unsigned long rel_size)
  4126. +{
  4127. +#ifdef __SPARC_LAZY_RELOC_WORKS
  4128. + (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
  4129. +#else
  4130. + _dl_parse_relocation_information(rpnt, rel_addr, rel_size);
  4131. +#endif
  4132. +}
  4133. - };
  4134. - return goof;
  4135. +int
  4136. +_dl_parse_relocation_information(struct dyn_elf *rpnt,
  4137. + unsigned long rel_addr,
  4138. + unsigned long rel_size)
  4139. +{
  4140. + return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
  4141. }
  4142. diff -urN uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-debug.h uClibc-0.9.28/ldso/ldso/x86_64/dl-debug.h
  4143. --- uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-debug.h 2006-05-02 10:47:27.000000000 -0600
  4144. +++ uClibc-0.9.28/ldso/ldso/x86_64/dl-debug.h 2006-04-28 00:14:35.000000000 -0600
  4145. @@ -30,7 +30,10 @@
  4146. */
  4147. static const char *_dl_reltypes_tab[] = {
  4148. - [0] "R_X86_64_NONE", "R_X86_64_64", "R_X86_64_PC32", "R_X86_64_GOT32",
  4149. - [4] "R_X86_64_PLT32", "R_X86_64_COPY", "R_X86_64_GLOB_DAT", "R_X86_64_JUMP_SLOT",
  4150. - [8] "R_X86_64_RELATIVE", "R_X86_64_GOTPCREL", "R_X86_64_32"
  4151. + [ 0] "R_X86_64_NONE", "R_X86_64_64", "R_X86_64_PC32", "R_X86_64_GOT32",
  4152. + [ 4] "R_X86_64_PLT32", "R_X86_64_COPY", "R_X86_64_GLOB_DAT", "R_X86_64_JUMP_SLOT",
  4153. + [ 8] "R_X86_64_RELATIVE", "R_X86_64_GOTPCREL", "R_X86_64_32", "R_X86_64_32S",
  4154. + [12] "R_X86_64_16", "R_X86_64_PC16", "R_X86_64_8", "R_X86_64_PC8",
  4155. + [16] "R_X86_64_DTPMOD64", "R_X86_64_DTPOFF64", "R_X86_64_TPOFF64", "R_X86_64_TLSGD",
  4156. + [20] "R_X86_64_TLSLD", "R_X86_64_DTPOFF32", "R_X86_64_GOTTPOFF", "R_X86_64_TPOFF32"
  4157. };
  4158. diff -urN uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-startup.h uClibc-0.9.28/ldso/ldso/x86_64/dl-startup.h
  4159. --- uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-startup.h 2006-05-02 10:47:27.000000000 -0600
  4160. +++ uClibc-0.9.28/ldso/ldso/x86_64/dl-startup.h 2006-04-28 00:14:35.000000000 -0600
  4161. @@ -6,7 +6,7 @@
  4162. *
  4163. * Parts taken from glibc/sysdeps/x86_64/dl-machine.h
  4164. */
  4165. -asm(
  4166. +__asm__ (
  4167. " .text\n"
  4168. " .align 16\n"
  4169. " .global _start\n"
  4170. @@ -42,10 +42,10 @@
  4171. /* Handle relocation of the symbols in the dynamic loader. */
  4172. static __always_inline
  4173. -void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
  4174. - unsigned long symbol_addr, unsigned long load_addr, Elf64_Sym *sym)
  4175. +void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, ElfW(Addr) *reloc_addr,
  4176. + ElfW(Addr) symbol_addr, ElfW(Addr) load_addr, ElfW(Sym) *sym)
  4177. {
  4178. - switch (ELF64_R_TYPE(rpnt->r_info)) {
  4179. + switch (ELF_R_TYPE(rpnt->r_info)) {
  4180. case R_X86_64_GLOB_DAT:
  4181. case R_X86_64_JUMP_SLOT:
  4182. *reloc_addr = symbol_addr + rpnt->r_addend;
  4183. @@ -63,8 +63,3 @@
  4184. _dl_exit(1);
  4185. }
  4186. }
  4187. -
  4188. -/* Transfer control to the user's application, once the dynamic loader is
  4189. - * done. This routine has to exit the current function, then call the
  4190. - * _dl_elf_main function. */
  4191. -#define START() return _dl_elf_main
  4192. diff -urN uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-syscalls.h uClibc-0.9.28/ldso/ldso/x86_64/dl-syscalls.h
  4193. --- uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-syscalls.h 2006-05-02 10:47:27.000000000 -0600
  4194. +++ uClibc-0.9.28/ldso/ldso/x86_64/dl-syscalls.h 2006-05-02 13:39:17.000000000 -0600
  4195. @@ -1,7 +1,8 @@
  4196. /* We can't use the real errno in ldso, since it has not yet
  4197. * been dynamicly linked in yet. */
  4198. +#define __UCLIBC_MMAP_HAS_6_ARGS__
  4199. +
  4200. +#include "sys/syscall.h"
  4201. extern int _dl_errno;
  4202. +#undef __set_errno
  4203. #define __set_errno(X) {(_dl_errno) = (X);}
  4204. -#include "sys/syscall.h"
  4205. -
  4206. -#define MMAP_HAS_6_ARGS
  4207. diff -urN uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-sysdep.h uClibc-0.9.28/ldso/ldso/x86_64/dl-sysdep.h
  4208. --- uClibc-0.9.28.orig/ldso/ldso/x86_64/dl-sysdep.h 2006-05-02 10:47:27.000000000 -0600
  4209. +++ uClibc-0.9.28/ldso/ldso/x86_64/dl-sysdep.h 2006-04-28 00:14:35.000000000 -0600
  4210. @@ -41,8 +41,6 @@
  4211. struct elf_resolve;
  4212. extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
  4213. -#define do_rem(result, n, base) ((result) = (n) % (base))
  4214. -
  4215. /* 4096 bytes alignment */
  4216. #define PAGE_ALIGN 0xfffff000
  4217. #define ADDR_ALIGN 0xfff
  4218. @@ -90,7 +88,7 @@
  4219. and compare it with the current value that we can get via
  4220. an RIP relative addressing mode. */
  4221. - asm ("movq 1f(%%rip), %1\n"
  4222. + __asm__ ("movq 1f(%%rip), %1\n"
  4223. "0:\tleaq _dl_start(%%rip), %0\n\t"
  4224. "subq %1, %0\n\t"
  4225. ".section\t.data\n"
  4226. diff -urN uClibc-0.9.28.orig/ldso/ldso/x86_64/elfinterp.c uClibc-0.9.28/ldso/ldso/x86_64/elfinterp.c
  4227. --- uClibc-0.9.28.orig/ldso/ldso/x86_64/elfinterp.c 2006-05-02 10:47:27.000000000 -0600
  4228. +++ uClibc-0.9.28/ldso/ldso/x86_64/elfinterp.c 2006-04-28 00:14:35.000000000 -0600
  4229. @@ -165,6 +165,7 @@
  4230. int reloc_type;
  4231. int symtab_index;
  4232. char *symname;
  4233. + ElfW(Sym) *sym;
  4234. ElfW(Addr) *reloc_addr;
  4235. ElfW(Addr) symbol_addr;
  4236. #if defined (__SUPPORT_LD_DEBUG__)
  4237. @@ -174,8 +175,9 @@
  4238. reloc_addr = (ElfW(Addr)*)(tpnt->loadaddr + (unsigned long)rpnt->r_offset);
  4239. reloc_type = ELF_R_TYPE(rpnt->r_info);
  4240. symtab_index = ELF_R_SYM(rpnt->r_info);
  4241. + sym = &symtab[symtab_index];
  4242. symbol_addr = 0;
  4243. - symname = strtab + symtab[symtab_index].st_name;
  4244. + symname = strtab + sym->st_name;
  4245. if (symtab_index) {
  4246. symbol_addr = (ElfW(Addr))_dl_find_hash(symname, scope, tpnt,
  4247. @@ -185,7 +187,7 @@
  4248. * might have been intentional. We should not be linking local
  4249. * symbols here, so all bases should be covered.
  4250. */
  4251. - if (unlikely(!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK)) {
  4252. + if (unlikely(!symbol_addr && ELF_ST_BIND(sym->st_info) != STB_WEAK)) {
  4253. _dl_dprintf(2, "%s: can't resolve symbol '%s'\n", _dl_progname, symname);
  4254. _dl_exit(1);
  4255. };
  4256. @@ -209,7 +211,7 @@
  4257. case R_X86_64_GLOB_DAT:
  4258. case R_X86_64_JUMP_SLOT:
  4259. - *reloc_addr = symbol_addr;
  4260. + *reloc_addr = symbol_addr + rpnt->r_addend;
  4261. break;
  4262. /* handled by elf_machine_relative()
  4263. @@ -217,33 +219,33 @@
  4264. *reloc_addr = map->l_addr + rpnt->r_addend;
  4265. break;
  4266. */
  4267. -#if 0
  4268. case R_X86_64_DTPMOD64:
  4269. + *reloc_addr = 1;
  4270. break;
  4271. case R_X86_64_DTPOFF64:
  4272. - *reloc_addr = symbol_addr + rpnt->r_addend;
  4273. + *reloc_addr = sym->st_value + rpnt->r_addend;
  4274. break;
  4275. case R_X86_64_TPOFF64:
  4276. - *reloc_addr = symbol_addr + rpnt->r_addend;
  4277. + *reloc_addr = sym->st_value + rpnt->r_addend - symbol_addr;
  4278. break;
  4279. case R_X86_64_32:
  4280. - *reloc_addr = symbol_addr + rpnt->r_addend;
  4281. + *(unsigned int *) reloc_addr = symbol_addr + rpnt->r_addend;
  4282. + /* XXX: should check for overflow eh ? */
  4283. break;
  4284. -#endif
  4285. case R_X86_64_COPY:
  4286. if (symbol_addr) {
  4287. #if defined (__SUPPORT_LD_DEBUG__)
  4288. if (_dl_debug_move)
  4289. _dl_dprintf(_dl_debug_file,
  4290. "\t%s move %d bytes from %x to %x\n",
  4291. - symname, symtab[symtab_index].st_size,
  4292. + symname, sym->st_size,
  4293. symbol_addr, reloc_addr);
  4294. #endif
  4295. _dl_memcpy((char *)reloc_addr,
  4296. (char *)symbol_addr,
  4297. - symtab[symtab_index].st_size);
  4298. + sym->st_size);
  4299. } else
  4300. _dl_dprintf(_dl_debug_file, "no symbol_addr to copy !?\n");
  4301. break;
  4302. @@ -261,7 +263,6 @@
  4303. return 0;
  4304. }
  4305. -#if 0
  4306. static int
  4307. _dl_do_lazy_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
  4308. ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
  4309. @@ -288,7 +289,7 @@
  4310. case R_X86_64_NONE:
  4311. break;
  4312. case R_X86_64_JUMP_SLOT:
  4313. - *reloc_addr = tpnt->loadaddr + symtab[symtab_index].st_value;
  4314. + *reloc_addr += (unsigned long)tpnt->loadaddr;
  4315. break;
  4316. default:
  4317. _dl_exit(1);
  4318. @@ -302,17 +303,13 @@
  4319. return 0;
  4320. }
  4321. -#endif
  4322. void
  4323. _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
  4324. unsigned long rel_addr,
  4325. unsigned long rel_size)
  4326. {
  4327. - _dl_parse_relocation_information(rpnt, rel_addr, rel_size);
  4328. -/* jump slot isnt working
  4329. (void)_dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
  4330. -*/
  4331. }
  4332. int
  4333. diff -urN uClibc-0.9.28.orig/ldso/ldso/x86_64/resolve.S uClibc-0.9.28/ldso/ldso/x86_64/resolve.S
  4334. --- uClibc-0.9.28.orig/ldso/ldso/x86_64/resolve.S 1969-12-31 17:00:00.000000000 -0700
  4335. +++ uClibc-0.9.28/ldso/ldso/x86_64/resolve.S 2006-04-28 00:14:35.000000000 -0600
  4336. @@ -0,0 +1,63 @@
  4337. +/*
  4338. + * This function is _not_ called directly. It is jumped to (so no return
  4339. + * address is on the stack) when attempting to use a symbol that has not yet
  4340. + * been resolved. The first time a jump symbol (such as a function call inside
  4341. + * a shared library) is used (before it gets resolved) it will jump here to
  4342. + * _dl_linux_resolve. When we get called the stack looks like this:
  4343. + * reloc_entry
  4344. + * tpnt
  4345. + *
  4346. + * This function saves all the registers, puts a copy of reloc_entry and tpnt
  4347. + * on the stack (as function arguments) then make the function call
  4348. + * _dl_linux_resolver(tpnt, reloc_entry). _dl_linux_resolver() figures out
  4349. + * where the jump symbol is _really_ supposed to have jumped to and returns
  4350. + * that to us. Once we have that, we overwrite tpnt with this fixed up
  4351. + * address. We then clean up after ourselves, put all the registers back how we
  4352. + * found them, then we jump to where the fixed up address, which is where the
  4353. + * jump symbol that got us here really wanted to jump to in the first place.
  4354. + * found them, then we jump to the fixed up address, which is where the jump
  4355. + * symbol that got us here really wanted to jump to in the first place.
  4356. + * -Erik Andersen
  4357. + */
  4358. +
  4359. +/* more info taken from glibc/sysdeps/x86_64/dl-trampoline.S */
  4360. +
  4361. +.text
  4362. +
  4363. +.global _dl_linux_resolve
  4364. +.type _dl_linux_resolve,%function
  4365. +.align 16
  4366. +
  4367. +_dl_linux_resolve:
  4368. + subq $56,%rsp
  4369. + /* Preserve registers otherwise clobbered. */
  4370. + movq %rax, (%rsp)
  4371. + movq %rcx, 8(%rsp)
  4372. + movq %rdx, 16(%rsp)
  4373. + movq %rsi, 24(%rsp)
  4374. + movq %rdi, 32(%rsp)
  4375. + movq %r8, 40(%rsp)
  4376. + movq %r9, 48(%rsp)
  4377. +
  4378. + movq 64(%rsp), %rsi /* Copy args pushed by PLT in register. */
  4379. + movq %rsi, %r11 /* Multiply by 24 */
  4380. + addq %r11, %rsi
  4381. + addq %r11, %rsi
  4382. + shlq $3, %rsi
  4383. + movq 56(%rsp), %rdi /* %rdi: link_map, %rsi: reloc_offset */
  4384. + call _dl_linux_resolver /* Call resolver. */
  4385. + movq %rax, %r11 /* Save return value */
  4386. +
  4387. + /* Get register content back. */
  4388. + movq 48(%rsp), %r9
  4389. + movq 40(%rsp), %r8
  4390. + movq 32(%rsp), %rdi
  4391. + movq 24(%rsp), %rsi
  4392. + movq 16(%rsp), %rdx
  4393. + movq 8(%rsp), %rcx
  4394. + movq (%rsp), %rax
  4395. +
  4396. + addq $72, %rsp /* Adjust stack(PLT did 2 pushes) */
  4397. + jmp *%r11 /* Jump to function address. */
  4398. +
  4399. +.size _dl_linux_resolve,.-_dl_linux_resolve
  4400. diff -urN uClibc-0.9.28.orig/ldso/libdl/Makefile uClibc-0.9.28/ldso/libdl/Makefile
  4401. --- uClibc-0.9.28.orig/ldso/libdl/Makefile 2006-05-02 10:47:27.000000000 -0600
  4402. +++ uClibc-0.9.28/ldso/libdl/Makefile 2006-04-28 00:14:35.000000000 -0600
  4403. @@ -29,12 +29,14 @@
  4404. endif
  4405. XXFLAGS+= $(XARCH_CFLAGS) $(CPU_CFLAGS) \
  4406. -DUCLIBC_RUNTIME_PREFIX=\"$(RUNTIME_PREFIX)\" \
  4407. - -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I. -I$(TOPDIR)include
  4408. + -fno-builtin -nostdinc -D_LIBC \
  4409. + -DLDSO_ELFINTERP=\"$(TARGET_ARCH)/elfinterp.c\" \
  4410. + -I$(TOPDIR)ldso/ldso/$(TARGET_ARCH) -I$(TOPDIR)ldso/include -I$(TOPDIR)ldso/ldso -I$(TOPDIR)include
  4411. XXFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
  4412. XXFLAGS_NOPIC:=$(XXFLAGS)
  4413. ifeq ($(DOPIC),y)
  4414. - XXFLAGS += $(PICFLAG) -D__LIBDL_SHARED__
  4415. + XXFLAGS += $(PICFLAG) -DSHARED
  4416. endif
  4417. ifeq ($(strip $(SUPPORT_LD_DEBUG)),y)
  4418. XXFLAGS+=-D__SUPPORT_LD_DEBUG__
  4419. diff -urN uClibc-0.9.28.orig/ldso/libdl/libdl.c uClibc-0.9.28/ldso/libdl/libdl.c
  4420. --- uClibc-0.9.28.orig/ldso/libdl/libdl.c 2006-05-02 10:47:27.000000000 -0600
  4421. +++ uClibc-0.9.28/ldso/libdl/libdl.c 2006-04-28 00:14:35.000000000 -0600
  4422. @@ -3,7 +3,7 @@
  4423. * Program to load an ELF binary on a linux system, and run it
  4424. * after resolving ELF shared library symbols
  4425. *
  4426. - * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
  4427. + * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
  4428. * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
  4429. * David Engel, Hongjiu Lu and Mitch D'Souza
  4430. *
  4431. @@ -30,12 +30,12 @@
  4432. */
  4433. -#define _GNU_SOURCE
  4434. +#define _GNU_SOURCE
  4435. #include <ldso.h>
  4436. #include <stdio.h>
  4437. -#if defined (__LIBDL_SHARED__)
  4438. +#ifdef SHARED
  4439. /* When libdl is loaded as a shared library, we need to load in
  4440. * and use a pile of symbols from ldso... */
  4441. @@ -52,6 +51,8 @@
  4442. extern struct r_debug *_dl_debug_addr;
  4443. extern unsigned long _dl_error_number;
  4444. extern void *(*_dl_malloc_function)(size_t);
  4445. +extern void _dl_run_init_array(struct elf_resolve *);
  4446. +extern void _dl_run_fini_array(struct elf_resolve *);
  4447. #ifdef __LDSO_CACHE_SUPPORT__
  4448. int _dl_map_cache(void);
  4449. int _dl_unmap_cache(void);
  4450. @@ -64,7 +65,7 @@
  4451. #endif
  4452. -#else /* __LIBDL_SHARED__ */
  4453. +#else /* SHARED */
  4454. /* When libdl is linked as a static library, we need to replace all
  4455. * the symbols that otherwise would have been loaded in from ldso... */
  4456. @@ -81,11 +82,11 @@
  4457. struct r_debug *_dl_debug_addr = NULL;
  4458. #define _dl_malloc malloc
  4459. #include "../ldso/dl-debug.c"
  4460. -#include "dl-progname.h"
  4461. +#include LDSO_ELFINTERP
  4462. #include "../ldso/dl-hash.c"
  4463. #define _dl_trace_loaded_objects 0
  4464. #include "../ldso/dl-elf.c"
  4465. -#endif /* __LIBDL_SHARED__ */
  4466. +#endif /* SHARED */
  4467. #ifdef __SUPPORT_LD_DEBUG__
  4468. # define _dl_if_debug_print(fmt, args...) \
  4469. @@ -126,7 +127,8 @@
  4470. "Unable to resolve symbol"
  4471. };
  4472. -void __attribute__ ((destructor)) dl_cleanup(void)
  4473. +void dl_cleanup(void) __attribute__ ((destructor));
  4474. +void dl_cleanup(void)
  4475. {
  4476. struct dyn_elf *d;
  4477. for (d = _dl_handles; d; d = d->next_handle) {
  4478. @@ -138,13 +140,12 @@
  4479. {
  4480. struct elf_resolve *tpnt, *tfrom;
  4481. struct dyn_elf *dyn_chain, *rpnt = NULL, *dyn_ptr, *relro_ptr, *handle;
  4482. - struct dyn_elf *dpnt;
  4483. ElfW(Addr) from;
  4484. struct elf_resolve *tpnt1;
  4485. void (*dl_brk) (void);
  4486. int now_flag;
  4487. struct init_fini_list *tmp, *runp, *runp2, *dep_list;
  4488. - int nlist, i;
  4489. + unsigned int nlist, i;
  4490. struct elf_resolve **init_fini_list;
  4491. /* A bit of sanity checking... */
  4492. @@ -169,12 +170,15 @@
  4493. * the application. Thus this may go away at some time
  4494. * in the future.
  4495. */
  4496. - tfrom = NULL;
  4497. - for (dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next) {
  4498. - tpnt = dpnt->dyn;
  4499. - if (tpnt->loadaddr < from
  4500. - && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr))
  4501. - tfrom = tpnt;
  4502. + {
  4503. + struct dyn_elf *dpnt;
  4504. + tfrom = NULL;
  4505. + for (dpnt = _dl_symbol_tables; dpnt; dpnt = dpnt->next) {
  4506. + tpnt = dpnt->dyn;
  4507. + if (tpnt->loadaddr < from
  4508. + && (tfrom == NULL || tfrom->loadaddr < tpnt->loadaddr))
  4509. + tfrom = tpnt;
  4510. + }
  4511. }
  4512. for(rpnt = _dl_symbol_tables; rpnt && rpnt->next; rpnt=rpnt->next);
  4513. @@ -233,11 +237,8 @@
  4514. runp->tpnt->init_fini = NULL; /* clear any previous dependcies */
  4515. for (dpnt = (ElfW(Dyn) *) runp->tpnt->dynamic_addr; dpnt->d_tag; dpnt++) {
  4516. if (dpnt->d_tag == DT_NEEDED) {
  4517. - char *name;
  4518. -
  4519. lpntstr = (char*) (runp->tpnt->dynamic_info[DT_STRTAB] +
  4520. dpnt->d_un.d_val);
  4521. - name = _dl_get_last_path_component(lpntstr);
  4522. _dl_if_debug_print("Trying to load '%s', needed by '%s'\n",
  4523. lpntstr, runp->tpnt->libname);
  4524. tpnt1 = _dl_load_shared_library(0, &rpnt, runp->tpnt, lpntstr, 0);
  4525. @@ -297,14 +298,14 @@
  4526. }
  4527. /* Sort the INIT/FINI list in dependency order. */
  4528. for (runp2 = dep_list; runp2; runp2 = runp2->next) {
  4529. - int j, k;
  4530. + unsigned int j, k;
  4531. for (j = 0; init_fini_list[j] != runp2->tpnt; ++j)
  4532. /* Empty */;
  4533. for (k = j + 1; k < nlist; ++k) {
  4534. - struct init_fini_list *runp = init_fini_list[k]->init_fini;
  4535. + struct init_fini_list *ele = init_fini_list[k]->init_fini;
  4536. - for (; runp; runp = runp->next) {
  4537. - if (runp->tpnt == runp2->tpnt) {
  4538. + for (; ele; ele = ele->next) {
  4539. + if (ele->tpnt == runp2->tpnt) {
  4540. struct elf_resolve *here = init_fini_list[k];
  4541. _dl_if_debug_print("Move %s from pos %d to %d in INIT/FINI list.\n", here->libname, k, j);
  4542. for (i = (k - j); i; --i)
  4543. @@ -367,7 +368,7 @@
  4544. }
  4545. }
  4546. -#if defined (__LIBDL_SHARED__)
  4547. +#ifdef SHARED
  4548. /* Run the ctors and setup the dtors */
  4549. for (i = nlist; i; --i) {
  4550. tpnt = init_fini_list[i-1];
  4551. @@ -384,8 +385,11 @@
  4552. (*dl_elf_func) ();
  4553. }
  4554. }
  4555. +
  4556. + _dl_run_init_array(tpnt);
  4557. }
  4558. -#endif
  4559. +#endif /* SHARED */
  4560. +
  4561. _dl_unmap_cache();
  4562. return (void *) dyn_chain;
  4563. @@ -450,9 +454,16 @@
  4564. return ret;
  4565. }
  4566. +#if 0
  4567. +void *dlvsym(void *vhandle, const char *name, const char *version)
  4568. +{
  4569. + return dlsym(vhandle, name);
  4570. +}
  4571. +#endif
  4572. +
  4573. static int do_dlclose(void *vhandle, int need_fini)
  4574. {
  4575. - struct dyn_elf *rpnt, *rpnt1;
  4576. + struct dyn_elf *rpnt, *rpnt1, *rpnt1_tmp;
  4577. struct init_fini_list *runp, *tmp;
  4578. ElfW(Phdr) *ppnt;
  4579. struct elf_resolve *tpnt, *run_tpnt;
  4580. @@ -460,7 +471,7 @@
  4581. void (*dl_brk) (void);
  4582. struct dyn_elf *handle;
  4583. unsigned int end;
  4584. - int i = 0, j;
  4585. + unsigned int i, j;
  4586. handle = (struct dyn_elf *) vhandle;
  4587. if (handle == _dl_symbol_tables)
  4588. @@ -491,13 +502,21 @@
  4589. for (j = 0; j < handle->init_fini.nlist; ++j) {
  4590. tpnt = handle->init_fini.init_fini[j];
  4591. if (--tpnt->usage_count == 0) {
  4592. - if (tpnt->dynamic_info[DT_FINI] && need_fini &&
  4593. + if ((tpnt->dynamic_info[DT_FINI]
  4594. + || tpnt->dynamic_info[DT_FINI_ARRAY])
  4595. + && need_fini &&
  4596. !(tpnt->init_flag & FINI_FUNCS_CALLED)) {
  4597. tpnt->init_flag |= FINI_FUNCS_CALLED;
  4598. - dl_elf_fini = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
  4599. - _dl_if_debug_print("running dtors for library %s at '%p'\n",
  4600. - tpnt->libname, dl_elf_fini);
  4601. - (*dl_elf_fini) ();
  4602. +#ifdef SHARED
  4603. + _dl_run_fini_array(tpnt);
  4604. +#endif
  4605. +
  4606. + if (tpnt->dynamic_info[DT_FINI]) {
  4607. + dl_elf_fini = (int (*)(void)) (tpnt->loadaddr + tpnt->dynamic_info[DT_FINI]);
  4608. + _dl_if_debug_print("running dtors for library %s at '%p'\n",
  4609. + tpnt->libname, dl_elf_fini);
  4610. + (*dl_elf_fini) ();
  4611. + }
  4612. }
  4613. _dl_if_debug_print("unmapping: %s\n", tpnt->libname);
  4614. @@ -541,8 +560,9 @@
  4615. for (rpnt1 = _dl_symbol_tables; rpnt1->next; rpnt1 = rpnt1->next) {
  4616. if (rpnt1->next->dyn == tpnt) {
  4617. _dl_if_debug_print("removing symbol_tables: %s\n", tpnt->libname);
  4618. + rpnt1_tmp = rpnt1->next->next;
  4619. free(rpnt1->next);
  4620. - rpnt1->next = rpnt1->next->next;
  4621. + rpnt1->next = rpnt1_tmp;
  4622. if (rpnt1->next)
  4623. rpnt1->next->prev = rpnt1;
  4624. break;
  4625. @@ -588,8 +608,9 @@
  4626. }
  4627. /*
  4628. - * Dump information to stderrr about the current loaded modules
  4629. + * Dump information to stderr about the current loaded modules
  4630. */
  4631. +#if 1
  4632. static char *type[] = { "Lib", "Exe", "Int", "Mod" };
  4633. int dlinfo(void)
  4634. @@ -660,16 +681,14 @@
  4635. {
  4636. char *strtab;
  4637. ElfW(Sym) *symtab;
  4638. - int hn, si;
  4639. - int sf;
  4640. - int sn = 0;
  4641. + unsigned int hn, si, sn, sf;
  4642. ElfW(Addr) sa;
  4643. sa = 0;
  4644. symtab = (ElfW(Sym) *) (pelf->dynamic_info[DT_SYMTAB]);
  4645. strtab = (char *) (pelf->dynamic_info[DT_STRTAB]);
  4646. - sf = 0;
  4647. + sf = sn = 0;
  4648. for (hn = 0; hn < pelf->nbucket; hn++) {
  4649. for (si = pelf->elf_buckets[hn]; si; si = pelf->chains[si]) {
  4650. ElfW(Addr) symbol_addr;
  4651. @@ -696,3 +715,4 @@
  4652. return 1;
  4653. }
  4654. }
  4655. +#endif
  4656. diff -urN uClibc-0.9.28.orig/libc/sysdeps/linux/i386/bits/syscalls.h uClibc-0.9.28/libc/sysdeps/linux/i386/bits/syscalls.h
  4657. --- uClibc-0.9.28.orig/libc/sysdeps/linux/i386/bits/syscalls.h 2006-05-02 10:47:27.000000000 -0600
  4658. +++ uClibc-0.9.28/libc/sysdeps/linux/i386/bits/syscalls.h 2006-04-28 00:14:35.000000000 -0600
  4659. @@ -4,17 +4,15 @@
  4660. # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
  4661. #endif
  4662. +#include <errno.h>
  4663. +
  4664. /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
  4665. * header files. It also defines the traditional `SYS_<name>' macros for older
  4666. * programs. */
  4667. #include <bits/sysnum.h>
  4668. -#ifndef __set_errno
  4669. -# define __set_errno(val) (*__errno_location ()) = (val)
  4670. -#endif
  4671. -
  4672. /*
  4673. - Some of the sneaky macros in the code were taken from
  4674. + Some of the sneaky macros in the code were taken from
  4675. glibc-2.2.5/sysdeps/unix/sysv/linux/i386/sysdep.h
  4676. */
  4677. @@ -22,7 +20,8 @@
  4678. /* We need some help from the assembler to generate optimal code. We
  4679. define some macros here which later will be used. */
  4680. -asm (".L__X'%ebx = 1\n\t"
  4681. +
  4682. +__asm__ (".L__X'%ebx = 1\n\t"
  4683. ".L__X'%ecx = 2\n\t"
  4684. ".L__X'%edx = 2\n\t"
  4685. ".L__X'%eax = 3\n\t"
  4686. @@ -56,7 +55,6 @@
  4687. ".endif\n\t"
  4688. ".endm\n\t");
  4689. -
  4690. #undef _syscall0
  4691. #define _syscall0(type,name) \
  4692. type name(void) \
  4693. @@ -90,7 +88,7 @@
  4694. type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  4695. { \
  4696. return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
  4697. -}
  4698. +}
  4699. #undef _syscall5
  4700. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  4701. @@ -100,10 +98,18 @@
  4702. return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
  4703. }
  4704. +#undef _syscall6
  4705. +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  4706. + type5,arg5,type6,arg6) \
  4707. +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
  4708. +{ \
  4709. +return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
  4710. +}
  4711. +
  4712. #define INLINE_SYSCALL(name, nr, args...) \
  4713. ({ \
  4714. unsigned int resultvar; \
  4715. - asm volatile ( \
  4716. + __asm__ __volatile__ ( \
  4717. LOADARGS_##nr \
  4718. "movl %1, %%eax\n\t" \
  4719. "int $0x80\n\t" \
  4720. @@ -125,6 +131,7 @@
  4721. #define LOADARGS_3 LOADARGS_1
  4722. #define LOADARGS_4 LOADARGS_1
  4723. #define LOADARGS_5 LOADARGS_1
  4724. +#define LOADARGS_6 LOADARGS_1 "push %%ebp ; movl %7, %%ebp\n\t"
  4725. #define RESTOREARGS_0
  4726. #define RESTOREARGS_1 \
  4727. @@ -133,6 +140,7 @@
  4728. #define RESTOREARGS_3 RESTOREARGS_1
  4729. #define RESTOREARGS_4 RESTOREARGS_1
  4730. #define RESTOREARGS_5 RESTOREARGS_1
  4731. +#define RESTOREARGS_6 "pop %%ebp\n\t" RESTOREARGS_1
  4732. #define ASMFMT_0()
  4733. #define ASMFMT_1(arg1) \
  4734. @@ -145,7 +153,8 @@
  4735. , "aD" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
  4736. #define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
  4737. , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
  4738. -
  4739. +#define ASMFMT_6(arg1, arg2, arg3, arg4, arg5, arg6) \
  4740. + , "a" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5), "m" (arg6)
  4741. #endif /* __ASSEMBLER__ */
  4742. #endif /* _BITS_SYSCALLS_H */
  4743. diff -urN uClibc-0.9.28.orig/libc/sysdeps/linux/powerpc/bits/syscalls.h uClibc-0.9.28/libc/sysdeps/linux/powerpc/bits/syscalls.h
  4744. --- uClibc-0.9.28.orig/libc/sysdeps/linux/powerpc/bits/syscalls.h 2006-05-02 10:47:27.000000000 -0600
  4745. +++ uClibc-0.9.28/libc/sysdeps/linux/powerpc/bits/syscalls.h 2006-04-28 00:14:35.000000000 -0600
  4746. @@ -5,67 +5,164 @@
  4747. # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
  4748. #endif
  4749. +#include <errno.h>
  4750. +
  4751. /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
  4752. * header files. It also defines the traditional `SYS_<name>' macros for older
  4753. * programs. */
  4754. #include <bits/sysnum.h>
  4755. -
  4756. -#define __STRINGIFY(s) __STRINGIFY2 (s)
  4757. -#define __STRINGIFY2(s) #s
  4758. -
  4759. -#undef JUMPTARGET
  4760. -#ifdef __PIC__
  4761. -#define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall@plt)
  4762. +/* Define a macro which expands inline into the wrapper code for a system
  4763. + call. This use is for internal calls that do not need to handle errors
  4764. + normally. It will never touch errno.
  4765. + On powerpc a system call basically clobbers the same registers like a
  4766. + function call, with the exception of LR (which is needed for the
  4767. + "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
  4768. + an error return status). */
  4769. +
  4770. +# undef INLINE_SYSCALL
  4771. +#if 1
  4772. +# define INLINE_SYSCALL(name, nr, args...) \
  4773. + ({ \
  4774. + INTERNAL_SYSCALL_DECL (sc_err); \
  4775. + long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
  4776. + if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
  4777. + { \
  4778. + __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
  4779. + sc_ret = -1L; \
  4780. + } \
  4781. + sc_ret; \
  4782. + })
  4783. #else
  4784. -#define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall)
  4785. +# define INLINE_SYSCALL(name, nr, args...) \
  4786. + ({ \
  4787. + INTERNAL_SYSCALL_DECL (sc_err); \
  4788. + long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
  4789. + if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
  4790. + { \
  4791. + sc_ret = __syscall_error(INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));\
  4792. + } \
  4793. + sc_ret; \
  4794. + })
  4795. #endif
  4796. -#define unified_syscall_body(name) \
  4797. - __asm__ ( \
  4798. - ".section \".text\"\n\t" \
  4799. - ".align 2\n\t" \
  4800. - ".globl " __STRINGIFY(name) "\n\t" \
  4801. - ".type " __STRINGIFY(name) ",@function\n\t" \
  4802. - #name":\tli 0," __STRINGIFY(__NR_##name) "\n\t" \
  4803. - "b " __MAKE_SYSCALL "\n\t" \
  4804. - ".size\t" __STRINGIFY(name) ",.""-" __STRINGIFY(name) "\n" \
  4805. - )
  4806. +/* Define a macro which expands inline into the wrapper code for a system
  4807. + call. This use is for internal calls that do not need to handle errors
  4808. + normally. It will never touch errno.
  4809. + On powerpc a system call basically clobbers the same registers like a
  4810. + function call, with the exception of LR (which is needed for the
  4811. + "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
  4812. + an error return status). */
  4813. +
  4814. +# undef INTERNAL_SYSCALL_DECL
  4815. +# define INTERNAL_SYSCALL_DECL(err) long int err
  4816. +
  4817. +# undef INTERNAL_SYSCALL
  4818. +# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
  4819. + ({ \
  4820. + register long int r0 __asm__ ("r0"); \
  4821. + register long int r3 __asm__ ("r3"); \
  4822. + register long int r4 __asm__ ("r4"); \
  4823. + register long int r5 __asm__ ("r5"); \
  4824. + register long int r6 __asm__ ("r6"); \
  4825. + register long int r7 __asm__ ("r7"); \
  4826. + register long int r8 __asm__ ("r8"); \
  4827. + register long int r9 __asm__ ("r9"); \
  4828. + register long int r10 __asm__ ("r10"); \
  4829. + register long int r11 __asm__ ("r11"); \
  4830. + register long int r12 __asm__ ("r12"); \
  4831. + LOADARGS_##nr(name, args); \
  4832. + __asm__ __volatile__ \
  4833. + ("sc \n\t" \
  4834. + "mfcr %0" \
  4835. + : "=&r" (r0), \
  4836. + "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
  4837. + "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
  4838. + : ASM_INPUT_##nr \
  4839. + : "cr0", "ctr", "memory"); \
  4840. + err = r0; \
  4841. + (int) r3; \
  4842. + })
  4843. +# define INTERNAL_SYSCALL(name, err, nr, args...) \
  4844. + INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
  4845. +
  4846. +# undef INTERNAL_SYSCALL_ERROR_P
  4847. +# define INTERNAL_SYSCALL_ERROR_P(val, err) \
  4848. + ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
  4849. +
  4850. +# undef INTERNAL_SYSCALL_ERRNO
  4851. +# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
  4852. +
  4853. +# define LOADARGS_0(name, dummy) \
  4854. + r0 = (long int)name
  4855. +# define LOADARGS_1(name, __arg1) \
  4856. + LOADARGS_0(name, 0); \
  4857. + r3 = (long int)__arg1
  4858. +# define LOADARGS_2(name, __arg1, __arg2) \
  4859. + LOADARGS_1(name, __arg1); \
  4860. + r4 = (long int)__arg2
  4861. +# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
  4862. + LOADARGS_2(name, __arg1, __arg2); \
  4863. + r5 = (long int)__arg3
  4864. +# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
  4865. + LOADARGS_3(name, __arg1, __arg2, __arg3); \
  4866. + r6 = (long int)__arg4
  4867. +# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
  4868. + LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
  4869. + r7 = (long int)__arg5
  4870. +# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
  4871. + LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
  4872. + r8 = (long int)__arg6
  4873. +
  4874. +# define ASM_INPUT_0 "0" (r0)
  4875. +# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
  4876. +# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
  4877. +# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
  4878. +# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
  4879. +# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
  4880. +# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
  4881. #undef _syscall0
  4882. -#define _syscall0(type,name) \
  4883. -type name(void); \
  4884. -unified_syscall_body(name)
  4885. +#define _syscall0(type,name) \
  4886. +type name(void){ \
  4887. + return (type) INLINE_SYSCALL(name, 0); \
  4888. +}
  4889. #undef _syscall1
  4890. #define _syscall1(type,name,type1,arg1) \
  4891. -type name(type1 arg1); \
  4892. -unified_syscall_body(name)
  4893. +type name(type1 arg1){ \
  4894. + return (type) INLINE_SYSCALL(name, 1, arg1); \
  4895. +}
  4896. #undef _syscall2
  4897. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  4898. -type name(type1 arg1, type2 arg2); \
  4899. -unified_syscall_body(name)
  4900. +type name(type1 arg1, type2 arg2){ \
  4901. + return (type) INLINE_SYSCALL(name, 2, arg1, arg2); \
  4902. +}
  4903. #undef _syscall3
  4904. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  4905. -type name(type1 arg1, type2 arg2, type3 arg3); \
  4906. -unified_syscall_body(name)
  4907. +type name(type1 arg1, type2 arg2, type3 arg3){ \
  4908. + return (type) INLINE_SYSCALL(name, 3, arg1, arg2, arg3); \
  4909. +}
  4910. #undef _syscall4
  4911. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  4912. -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4); \
  4913. -unified_syscall_body(name)
  4914. +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4){ \
  4915. + return (type) INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4); \
  4916. +}
  4917. #undef _syscall5
  4918. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
  4919. -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5); \
  4920. -unified_syscall_body(name)
  4921. +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5){ \
  4922. + return (type) INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); \
  4923. +}
  4924. #undef _syscall6
  4925. #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
  4926. -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6); \
  4927. -unified_syscall_body(name)
  4928. +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6){ \
  4929. + return (type) INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \
  4930. +}
  4931. #endif /* _BITS_SYSCALLS_H */