No MULTIPLE CALL TO SEGMENT warning where it should be...

Please consider the following code.

//--- module main.c ---

...

void main() {
        ...
        set_status_word(...);
        ...
}

//--- module can.c ---

...

void CAN_int_handler(void) interrupt 7 {
        ...
        set_status_word(...);
        ...
}

//--- module utils.c ---

...

void set_status_word(...) {
        ...
}

If you replace the calls to set_status_word() with calls to printf(), the linker issues a "multiple call to segment" warning, but, like this, this code causes no warnings. Why not? I looked at the assembler output of the set_status_word() function and noticed that it isn't using absolute register addressing. Can this relate somehow?

Parents
  • What exactly does set_status_word() do ?

    If it is not using any overlayed memory (no local non-static variables, few enough parameters so they can be passed in registers), then the linker should not issue a warning.

    However, the lack of a warning does not mean that things can go awry. For example if the function modifies global variables. In this case, however, it is the programmers job to make sure that multiple calls of the function work correctly.

Reply
  • What exactly does set_status_word() do ?

    If it is not using any overlayed memory (no local non-static variables, few enough parameters so they can be passed in registers), then the linker should not issue a warning.

    However, the lack of a warning does not mean that things can go awry. For example if the function modifies global variables. In this case, however, it is the programmers job to make sure that multiple calls of the function work correctly.

Children
More questions in this forum