Skip to content

[SR-3250] Glibc does not have dladdr(). #45838

Open
@norio-nomura

Description

@norio-nomura
Previous ID SR-3250
Radar None
Original Reporter @norio-nomura
Type Bug
Environment

Swift version 3.0.2 (swift-3.0.2-PREVIEW-1)

Additional Detail from JIRA
Votes 1
Component/s Standard Library
Labels Bug, Linux, SDKOverlay
Assignee None
Priority Medium

md5: 658a93e9ba02bcc5f6be291ef597711c

Issue Description:

# swift
Welcome to Swift version 3.0.2 (swift-3.0.2-PREVIEW-1). Type :help for assistance.
  1> :type lookup dlsym
no type was found matching 'dlsym'
  1> :type lookup dladdr
no type was found matching 'dladdr'
  1> import Glibc
  2> :type lookup dlsym 
@discardableResult func dlsym(_ __handle: Swift.UnsafeMutableRawPointer!, _ __name: Swift.UnsafePointer<Swift.Int8>) -> Swift.UnsafeMutableRawPointer!
  2> :type lookup dladdr 
no type was found matching 'dladdr'
  2>  

It seems that Glibc was imported without defining `__USE_GNU`.
/usr/include/dlfcn.h:

#ifdef __USE_GNU
/* Structure containing information about object searched using
   `dladdr'.  */
typedef struct
{
  const char *dli_fname;        /* File name of defining object.  */
  void *dli_fbase;              /* Load address of that object.  */
  const char *dli_sname;        /* Name of nearest symbol.  */
  void *dli_saddr;              /* Exact value of nearest symbol.  */
} Dl_info;

/* Fill in *INFO with the following information about ADDRESS.
   Returns 0 iff no shared object's segments contain that address.  */
extern int dladdr (const void *__address, Dl_info *__info)
     __THROW __nonnull ((2));

Ubuntu have

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxPlatform: LinuxSDKOverlaybugA deviation from expected or documented behavior. Also: expected but undesirable behavior.standard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions