Ignore:
Timestamp:
Mar 14, 2023, 4:21:05 PM (16 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
1afd9ccb, 360bfe41, 6e6989c
Parents:
5217569 (diff), c19ca4b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/interpose.cfa

    r5217569 rdbae916  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  2 13:56:26 2023
    13 // Update Count     : 191
    14 //
    15 
    16 #include <stdarg.h>                                                                             // va_start, va_end
     12// Last Modified On : Mon Mar 13 22:39:12 2023
     13// Update Count     : 193
     14//
     15
    1716#include <stdio.h>
    18 #include <string.h>                                                                             // strlen
    1917#include <unistd.h>                                                                             // _exit, getpid
    20 #include <signal.h>
    2118extern "C" {
    2219#include <dlfcn.h>                                                                              // dlopen, dlsym
     
    2421}
    2522
    26 #include "bits/debug.hfa"
    2723#include "bits/defs.hfa"
    2824#include "bits/signal.hfa"                                                              // sigHandler_?
     
    4036
    4137typedef void (* generic_fptr_t)(void);
     38
    4239static generic_fptr_t do_interpose_symbol( void * library, const char symbol[], const char version[] ) {
    43         const char * error;
    44 
    4540        union { generic_fptr_t fptr; void * ptr; } originalFunc;
    4641
    4742        originalFunc.ptr = dlsym( library, symbol );
    48         error = dlerror();
    49         if ( error ) abort( "interpose_symbol : internal error, %s\n", error );
    50 
     43        if ( ! originalFunc.ptr ) {                                                             // == nullptr
     44                abort( "interpose_symbol : internal error, %s\n", dlerror() );
     45        } // if
    5146        return originalFunc.fptr;
    5247}
     
    5752        library = RTLD_NEXT;
    5853        #else
     54        // missing RTLD_NEXT => must hard-code library name, assuming libstdc++
    5955        library = dlopen( "libc.so.6", RTLD_LAZY );
    60         if ( ! library ) {
    61                 const char * error = dlerror();
    62                 if ( error ) {
    63                         abort( "interpose_symbol : failed to open libc, %s\n", error );
    64                 } // if
     56        if ( ! library ) {                                                                      // == nullptr
     57                abort( "interpose_symbol : failed to open libc, %s\n", dlerror() );
    6558        } // if
    66         #endif
    67 
    68         return do_interpose_symbol(library, symbol, version);
     59        #endif // RTLD_NEXT
     60
     61        return do_interpose_symbol( library, symbol, version );
    6962}
    7063
Note: See TracChangeset for help on using the changeset viewer.