Share to: share facebook share twitter share wa share telegram print page

Shared library

A shared library or shared object is a computer file that contains executable code designed to be used by multiple computer programs or other libraries at runtime.

When running a program that is configured to use a shared library, the operating system loads the shared library from a file (other than the program's executable file) into memory at load time or runtime. For perspective, a program can alternatively be monolithic -- built to include the executable code of the library in its executable file, but the library code embedded in the program's executable file is not usable by other programs.

Shared libraries can be statically linked at compile-time, meaning that references to the library are resolved and the library is allocated memory when the executable file is created.[citation needed] But often linking of shared libraries is postponed until they are loaded.[dubiousdiscuss]

Most modern operating systems use the same format for both shared libraries and executable files.[NB 1] This offers two main advantages: first, it requires only one loader (building and maintaining a single loader is considered well worth any added complexity).[citation needed] Secondly, it allows an executable file to be used as a shared library (if it has a symbol table). Examples of file formats use for both shared libraries and executable files include ELF, Mach-O, and PE.

In some older environments such as 16-bit Windows or MPE for the HP 3000, only stack-based data (local) was allowed in shared library code, or other significant restrictions were placed on shared library code.

Memory sharing

Library code may be shared in memory by multiple processes, and on disk. If virtual memory is used, processes would execute the same physical page of RAM that is mapped into the different address spaces of the processes. This has advantages. For instance, on the OpenStep system, applications were often only a few hundred kilobytes in size and loaded quickly; most of their code was located in libraries that had already been loaded for other purposes by the operating system.[citation needed]

Programs can accomplish RAM sharing by using position-independent code, as in Unix, which leads to a complex but flexible architecture, or by using common virtual addresses, as in Windows and OS/2. These systems ensure, by various means, like pre-mapping the address space and reserving slots for each shared library, that code has a high probability of being shared. A third alternative is single-level store, as used by the IBM System/38 and its successors. This allows position-dependent code, but places no significant restrictions on where code can be placed or how it can be shared.

In some cases, different versions of shared libraries can cause problems, especially when libraries of different versions have the same file name, and different applications installed on a system each require a specific version. Such a scenario is known as DLL hell, named after the Windows and OS/2 DLL file. Most modern operating systems after 2001 have clean-up methods to eliminate such situations or use application-specific "private" libraries.[1]

Dynamic linking

Dynamic linking or late binding is linking performed while a program is being loaded (load time) or executed (runtime), rather than when the executable file is created. A dynamically linked library (dynamic-link library, or DLL, under Windows and OS/2; shareable image under OpenVMS;[2] dynamic shared object, or DSO, under Unix-like systems) is a library intended for dynamic linking. Only a minimal amount of work is done by the linker when the executable file is created; it only records what library routines the program needs and the index names or numbers of the routines in the library. The majority of the work of linking is done at the time the application is loaded (load time) or during execution (runtime). Usually, the necessary linking program, called a "dynamic linker" or "linking loader", is actually part of the underlying operating system. (However, it is possible, and not exceedingly difficult, to write a program that uses dynamic linking and includes its own dynamic linker, even for an operating system that itself provides no support for dynamic linking.)

Programmers originally developed dynamic linking in the Multics operating system, starting in 1964, and the MTS (Michigan Terminal System), built in the late 1960s.[3]

Optimizations

Since shared libraries on most systems do not change often, systems can compute a likely load address for each shared library on the system before it is needed and store that information in the libraries and executables. If every shared library that is loaded has undergone this process, then each will load at its predetermined address, which speeds up the process of dynamic linking. This optimization is known as prebinding or prelinking on macOS and Linux, respectively. IBM z/VM uses a similar technique, called "Discontinuous Saved Segments" (DCSS).[4] Disadvantages of this technique include the time required to precompute these addresses every time the shared libraries change, the inability to use address space layout randomization, and the requirement of sufficient virtual address space for use (a problem that will be alleviated by the adoption of 64-bit architectures, at least for the time being).

Locating libraries at runtime

Loaders for shared libraries vary widely in functionality. Some depend on the executable storing explicit paths to the libraries. Any change to the library naming or layout of the file system will cause these systems to fail. More commonly, only the name of the library (and not the path) is stored in the executable, with the operating system supplying a method to find the library on disk, based on some algorithm.

If a shared library that an executable depends on is deleted, moved, or renamed, or if an incompatible version of the library is copied to a place that is earlier in the search, the executable would fail to load. This is called dependency hell, existing on many platforms. The (infamous) Windows variant is commonly known as DLL hell. This problem cannot occur if each version of each library is uniquely identified and each program references libraries only by their full unique identifiers. The "DLL hell" problems with earlier Windows versions arose from using only the names of libraries, which were not guaranteed to be unique, to resolve dynamic links in programs. (To avoid "DLL hell", later versions of Windows rely largely on options for programs to install private DLLs—essentially a partial retreat from the use of shared libraries—along with mechanisms to prevent replacement of shared system DLLs with earlier versions of them.)

Microsoft Windows

Microsoft Windows checks the registry to determine the proper place to load DLLs that implement COM objects, but for other DLLs it will check the directories in a defined order. First, Windows checks the directory where it loaded the program (private DLL[1]); any directories set by calling the SetDllDirectory() function; the System32, System, and Windows directories; then the current working directory; and finally the directories specified by the PATH environment variable.[5] Applications written for the .NET Framework (since 2002), also check the Global Assembly Cache as the primary store of shared dll files to remove the issue of DLL hell.

OpenStep

OpenStep used a more flexible system, collecting a list of libraries from a number of known locations (similar to the PATH concept) when the system first starts. Moving libraries around causes no problems at all, although users incur a time cost when first starting the system.

Unix-like systems

Most Unix-like systems have a "search path" specifying file-system directories in which to look for dynamic libraries. Some systems specify the default path in a configuration file, others hard-code it into the dynamic loader. Some executable file formats can specify additional directories in which to search for libraries for a particular program. This can usually be overridden with an environment variable, although it is disabled for setuid and setgid programs, so that a user can't force such a program to run arbitrary code with root permissions. Developers of libraries are encouraged to place their dynamic libraries in places in the default search path. On the downside, this can make installation of new libraries problematic, and these "known" locations quickly become home to an increasing number of library files, making management more complex.

Dynamic loading

Dynamic loading, a subset of dynamic linking, involves a dynamically linked library loading and unloading at runtime on request. Such a request may be made implicitly or explicitly. Implicit requests are made when a compiler or static linker adds library references that include file paths or simply file names.[citation needed] Explicit requests are made when applications make direct calls to an operating system's API.

Most operating systems that support dynamically linked libraries also support dynamically loading such libraries via a run-time linker API. For instance, Microsoft Windows uses the API functions LoadLibrary, LoadLibraryEx, FreeLibrary and GetProcAddress with Microsoft Dynamic Link Libraries; POSIX-based systems, including most UNIX and UNIX-like systems, use dlopen, dlclose and dlsym. Some development systems automate this process.

Notes

  1. ^ Some older systems, e.g., Burroughs MCP, Multics, also have a single format

Further reading

References

  1. ^ a b Anderson, Rick (2000-01-11). "The End of DLL Hell". microsoft.com. Archived from the original on 2001-06-05. Retrieved 2012-01-15. Private DLLs are DLLs that are installed with a specific application and used only by that application.
  2. ^ "VSI OpenVMS Linker Utility Manual" (PDF). VSI. August 2019. Retrieved 2021-01-31.
  3. ^ "A History of MTS". Information Technology Digest. 5 (5).
  4. ^ IBM Corporation (2011). Saved Segments Planning and Administration (PDF). Retrieved Jan 29, 2022.
  5. ^ "Dynamic-Link Library Search Order". Microsoft Developer Network Library. Microsoft. 2012-03-06. Archived from the original on 9 May 2012. Retrieved 2012-05-20.

Read other articles:

The United States has had a two-party system for much of its history, and the two major parties have nominated vice presidential candidates in most presidential elections.[1] Since the ratification of the United States Constitution in 1789, there have been 59 unsuccessful major party candidates for Vice President of the United States. Eight other individuals have served as the main running mate to a third party or independent presidential candidate who won at least ten percent of the ...

The Right ReverendHenry Pryor Almon AbbottD.D., LL.D.Bishop of LexingtonAlmon AbbottChurchEpiscopal ChurchDioceseLexingtonElectedJanuary 30, 1929In office1929–1945PredecessorLewis W. BurtonSuccessorWilliam R. MoodyOrdersOrdination1905by Clarendon WorrellConsecrationMay 15, 1929by John Gardner MurrayPersonal detailsBorn(1881-07-11)July 11, 1881Halifax, Nova Scotia, CanadaDiedApril 4, 1945(1945-04-04) (aged 63)Lexington, Kentucky, United StatesNationalityCanadianDenominationAng...

Piste met circuspaarden De circuspiste is het centraal gelegen ronde middendeel van een circustent, van waaruit de voorstellingen gegeven worden. De piste wordt omgeven door een ongeveer 50-60 centimeter hoge en brede rand om een afscheiding te vormen tussen publiek en de optredende dieren en artiesten. Er is slechts aan één zijde een uitgang, meestal afgesloten door zware gordijnen, enigszins vergelijkbaar met de coulissen in een theater, en daarboven is de orkestbak. Het publiek zit er in...

Imagen de Lower Manhattan el 11 de septiembre de 2001 vista de la Estación Espacial Internacional. El intenso humo podía verse desde satélite. Los efectos en la salud derivados de los ataques del 11 de septiembre de 2001 en Nueva York se refiere a las enfermedades, daños y secuelas ocasionadas en sobrevivientes los atentados terroristas. A los pocos segundos del colapso del World Trade Center; los materiales de construcción, los equipos electrónicos y los muebles fueron pulverizados y e...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (يونيو 2019) فرد كاري   معلومات شخصية الميلاد 12 يونيو 1943 (80 سنة)  مواطنة الولايات المتحدة  الحياة العملية المهنة مصارع محترف  الرياضة المصارعة المحترفة  تعديل...

بدر أرسلان عبد القادر دمشقية معلومات شخصية تاريخ الوفاة 1954 تعديل مصدري - تعديل   يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (فبراير 2016) هذه المقالة يتيمة إذ ت...

Untuk pulau yang bernama-sama, lihat Pulau Batam. Kota BatamKotaTranskripsi bahasa daerah • Abjad JawiبتمDari atas, kiri ke kanan: Jembatan Barelang, ikon Welcome to Batam, Suasana Kota Batam, Masjid Sultan Mahmud Riayat Syah, Gereja Katolik Nha Tho Duc Me Vo Nhiem LambangJulukan: Bandar Dunia MadaniSingapore van RiouwarchipelPetaKota BatamPetaTampilkan peta SumatraKota BatamKota Batam (Indonesia)Tampilkan peta IndonesiaKoordinat: 1°07′48″N 104°03′11″E࿯...

Serguéi LavrovСерге́й Ви́кторович Лавро́в Lavrov en 2022. Ministro de Asuntos Exteriores de Rusia Actualmente en el cargo Desde el 24 de febrero de 2004Presidente Vladímir Putin (2004-2008, 2012-)Dmitri Medvédev (2008-2012)Predecesor Ígor Ivanov Representante Permanente de Rusia ante las Naciones Unidas 22 de septiembre de 1994-12 de julio de 2004Presidente Borís Yeltsin (1994-2000)Vladímir Putin (2000-2004)Predecesor Yuli VorontsovSucesor Andréi Denísov Infor...

43°14′13″N 45°30′03″E / 43.23694°N 45.50083°E / 43.23694; 45.50083 Kulary (Russian: Кулары, Chechen: ГӀулара,[1] Ġulara) is a rural locality (a selo) in Achkhoy-Martanovsky District, Chechnya. Administrative and municipal status Municipally, Kulary is incorporated as Kularinskoye rural settlement. It is the administrative center of the municipality and is the only settlement included in it.[2] Geography Map of Achkhoy-Martanovs...

Jun Inoue井上 順Jun Inoue in 1966Born (1947-02-21) February 21, 1947 (age 76)Shibuya, Tokyo, JapanOther namesJunji Inoue (former stage name)EducationSeijo Gakuen Junior High School and High School (dropped out)OccupationsTarentosingeractorYears active1963–AgentOh EnterpriseSpouseEmi Aoki (–1982)Websitewww.oh-enter.co.jp/artist/2 (in Japanese) Jun Inoue (井上 順, Inoue Jun, born 21 February 1947)[1] is a Japanese tarento, singer, actor, and comedian. Hi...

International cinema operator Cinema City International N.V.TypeSubsidiaryIndustryEntertainment and mediaFounded1929FounderMoshe Greidinger (senior)HeadquartersRotterdam, The Netherlands (registered office)Area servedCentral and Eastern Europe, IsraelKey peopleMooky Greidinger (CEO)ServicesMovie theatersRevenue€267.45 million (2011)[1]Operating income€24.72 million (2011)[1]Net income€21.37 million (2011)[1]Total assets€340.24 million (2011)[1]Total equ...

British actress and singer (born 1987) Cynthia ErivoErivo at the 2018 Tribeca Film FestivalBorn (1987-01-08) 8 January 1987 (age 36)Stockwell, London, EnglandAlma materRoyal Academy of Dramatic ArtOccupation(s)Actress, singerYears active2011–presentAwardsFull listMusical careerGenres R&B soul urban contemporary gospel Broadway Instrument(s)VocalsWebsitewww.cynthiaerivo.net Musical artist Cynthia Erivo (/əˈriːvoʊ/;[1] born 8 January 1987)[2] is an Engli...

This article is about the city in British Columbia. For the neighbouring township, see Langley, British Columbia (district municipality). For other uses, see Langley. City in British Columbia, CanadaLangleyCityCity of LangleyLangley City Hall FlagCoat of armsNickname: Langley CityMotto(s): Strength of Purpose, Spirit of CommunityLocation of Langley City in Metro VancouverCoordinates: 49°06′14″N 122°39′24″W / 49.10389°N 122.65667°W / 49.10389; -122...

A major contributor to this article appears to have a close connection with its subject. It may require cleanup to comply with Wikipedia's content policies, particularly neutral point of view. Please discuss further on the talk page. (March 2019) (Learn how and when to remove this template message) Swedish songwriter Peter HallströmBackground informationBirth namePeter Berno HallströmBorn (1965-01-19) 19 January 1965 (age 58)SwedenOccupation(s)Songwriter, musician, record and sound pro...

Fictional script in the fantasy works of J. R. R. Tolkien TengwarThe word Tengwar written using the Tengwar script in the Quenya modeScript type Alternative abugida or alphabet according to the modeCreatorJ. R. R. TolkienTime period1930s–presentDirectionleft-to-right Languagesa number of Tolkien's constructed languages, Quenya and Sindarin, EnglishRelated scriptsParent systemsSaratiTengwarISO 15924ISO 15924Teng (290), ​Tengwar This article contains phonetic transcripti...

Sauber Formula One car Sauber C35The Sauber C35, driven by Marcus Ericsson, during the 2016 Malaysian Grand Prix.CategoryFormula OneConstructorSauberDesigner(s)Mark Smith (Technical Director) Eric Gandelin (Chief Designer)Elliot Dason-Barber (Head of Vehicle Performance)Seamus Mullarkey (Head of Aerodynamic Research) Mariano Alperin (Head of Aerodynamic Development)PredecessorSauber C34SuccessorSauber C36Technical specificationsChassisCarbon-fibre composite survival cellEngineFerrari 061 1.6&...

Bosques templados de Northland Sendero en el parque nacional de Egmont en la región de Taranaki, Isla del Norte de Nueva Zelanda.Bioma: Bosques templados de frondosas y mixtosExtensión: 84,041 km2Estado de conservación: En peligro críticoPaíses Nueva Zelanda Nueva Zelanda Ecorregiones – WWF Mapa de Bosques templados de Northland [editar datos en Wikidata] Los bosques templados de Northland, también conocidos como bosques templados de la Isla Norte, son una ecorregión d...

District in Red River Delta, VietnamQuốc Oai district Huyện Quốc OaiDistrictThầy PagodaQuốc Oai districtCoordinates: 20°59′30″N 105°38′33″E / 20.991629°N 105.642635°E / 20.991629; 105.642635Country VietnamRegionRed River DeltaMunicipalityHanoiCapitalQuốc OaiTime zoneUTC+7 (Indochina Time) Quốc Oai is a district (huyện) of Hanoi in the Red River Delta region of Vietnam. Quốc Oai district is bordered by Hoài Đức district to the east...

Integration method to calculate volume Part of a series of articles aboutCalculus Fundamental theorem Limits Continuity Rolle's theorem Mean value theorem Inverse function theorem Differential Definitions Derivative (generalizations) Differential infinitesimal of a function total Concepts Differentiation notation Second derivative Implicit differentiation Logarithmic differentiation Related rates Taylor's theorem Rules and identities Sum Product Chain Power Quotient L'Hôpital's rule Inv...

McKesson Europe AG Тип Дочерняя компания Основание 1835 Расположение  Германия: Штутгарт Отрасль ФармацевтикаРозничная торговля Собственный капитал ▼ €1,893 млрд (2017)[1] Оборот ▼ €20,644 млрд (2017)[1] Чистая прибыль ▼ €-0,805 млрд (2017)[1] Активы ▼ €6,858 млрд (2017)[1] Число сот...

Kembali kehalaman sebelumnya