~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to routines/dld/remove.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* remove.c -- remove an explicitly defined symbol. */
 
2
 
 
3
/* This file is part of DLD, a dynamic link/unlink editor for C.
 
4
 
 
5
   Copyright (C) 1990 by W. Wilson Ho.
 
6
 
 
7
   The author can be reached electronically by how@cs.ucdavis.edu or
 
8
   through physical mail at:
 
9
 
 
10
   W. Wilson Ho
 
11
   Division of Computer Science
 
12
   University of California at Davis
 
13
   Davis, CA 95616
 
14
 */
 
15
 
 
16
/* This program is free software; you can redistribute it and/or modify it
 
17
   under the terms of the GNU General Public License as published by the
 
18
   Free Software Foundation; either version 1, or (at your option) any
 
19
   later version. */
 
20
 
 
21
#include "defs.h"
 
22
 
 
23
/*
 
24
 *  remove a previously defined symbol defined by dld_define().
 
25
 *  If symbol is not defined by dld_fine, this function becomes no-op.
 
26
 */
 
27
void
 
28
dld_remove_defined_symbol (name)
 
29
const char *name;
 
30
{
 
31
    register symbol *sp;
 
32
    register char *p;
 
33
 
 
34
    if (name == 0)
 
35
        return;
 
36
 
 
37
    p = (char *) _dld_malloc (strlen(name) +2);
 
38
    *p = '_';
 
39
    strcpy (p+1, name);
 
40
 
 
41
    sp = _dld_getsym_soft (p);
 
42
    free (p);
 
43
 
 
44
    if (sp->defined_by && sp->defined_by == _dld_dummy_entry) {
 
45
        register struct file_chain *p = sp->referenced_by;
 
46
        register struct file_chain *prev = 0;
 
47
 
 
48
        while (p)
 
49
            if (p->entry->ref_count == 0) {
 
50
                del_link_list_elt (sp->referenced_by, prev, p, next);
 
51
            } else {
 
52
                p->entry->undefined_symbol_count++;
 
53
                prev = p;
 
54
                p = p->next;
 
55
            }
 
56
 
 
57
        if (sp->referenced_by) {
 
58
            dld_undefined_sym_count++;
 
59
            sp->value = 0;
 
60
        }
 
61
 
 
62
#ifndef linux
 
63
        if (sp->defined == (N_COMM | N_EXT) && sp->value) {
 
64
#else
 
65
        if (sp->defined == (N_TYPE | N_EXT) && sp->value) {
 
66
#endif
 
67
            free ((void *)sp->value);
 
68
            sp->value = 0;
 
69
        }
 
70
 
 
71
        sp->defined = 0;
 
72
        sp->defined_by = 0;
 
73
 
 
74
        if (sp->referenced_by) {
 
75
            _dld_patch_all_files (_dld_latest_entry);
 
76
            _dld_exec_flags_valid = 0;
 
77
        }
 
78
    }
 
79
 
 
80
} /* dld_remove_defined_symbol */