[oi-dev] bacula, libraries and function addresses

Alexander Pyhalov alp at rsu.ru
Sat Jan 11 12:42:02 UTC 2014


Hello.
I'm trying to create bacula component.
However, while testing it I found out an interesting problem. As always, 
not sure, who is right.

Bacula has the following code in shared library libbaccfg.so:

if (items[i].handler == store_pint32 ||
                     items[i].handler == store_int32 ||
                     items[i].handler == store_size32) {
             *(uint32_t *)(items[i].value) = items[i].default_value;

where store_pint32 is defined as

void store_pint32(LEX *lc, RES_ITEM *item, int index, int pass);

in lib/parse_conf.h.

In bacula director code (src/dird/dird_conf.c), which is linked to this 
library and which also includes lib/parse_conf.h
there is an array of structures (items):

struct RES_ITEM {
    const char *name;                  /* Resource name i.e. Director, 
... */
    MSG_RES_HANDLER *handler;          /* Routine storing the resource 
item */
    union {
       char **value;                   /* Where to store the item */
       char **charvalue;
       uint32_t ui32value;
       int32_t i32value;
       uint64_t ui64value;
       int64_t i64value;
       bool boolvalue;
       utime_t utimevalue;
       RES *resvalue;
       RES **presvalue;
    };
    int32_t  code;                     /* item code/additional info */
    uint32_t  flags;                   /* flags: default, required, ... 
*/
    int32_t  default_value;            /* default value */
};
....

static RES_ITEM dir_items[] = {
...
    {"maximumconsoleconnections", store_pint32, 
ITEM(res_dir.MaxConsoleConnect), 0, ITEM_DEFAULT, 20},
...
    {NULL, NULL, {0}, 0, 0, 0}
};

But when I check store_pint32 addresses  in bacula director code and in 
libbaccfg.so they are different:
item.handler=80636f4
store_pint32=feda730b

I just don't understand... Are pointers for store_pint32 in library and 
in code which uses it supposed to be the same? And why on earth they are 
not?...
-- 
System Administrator of Southern Federal University Computer Center




More information about the oi-dev mailing list