0

I'm trying to link a symbol's file with mangled generated ones from the header. (matching ROM located functions to the RAM ones.)

In the .sym I have a function with "PFvv" parameter, normally demangled to -> VOID (fn*)(VOID).

The compiler is instead producing the following output as parameter: PFYvv

Result: the linker doesn't link.

Questions:

What does the Y stands for? Is there a reference doc for ARM mangling?

.sym mangled name:

_ZN10CCasd15lolEP13strPcPFvvEhPvm

compiler generated name:

_ZN10CCasd15lolEP13strPcPFYvvEhPvm

.h definition

class CCasd{
    static int lol(in_str*h, char* name, void(*fn)(void), unsigned char p, void *s, unsigned long l);
};

POST-ANSWER CODE:

Here is how you can generate both the PFvv and the PFYvv mangled names:

#ifdef          __cplusplus
extern  "C" {                               /* C declarations in C++     */
#endif

class CCASD {
public:
    static int lol(in_str*h, char* name, void(*fn)(void), unsigned char p, void *s, unsigned long l);//Will be PFYvv
};

#ifdef          __cplusplus
}                                           /* End of C declarations     */
#endif

class CCASD {
public:
    static int lol(in_str*h, char* name, void(*fn)(void), unsigned char p, void *s, unsigned long l);//Will be PFvv
};
Kons
  • 94
  • 7

1 Answers1

2

Apparently, the ARM ABI is based on the more common Itanium ABI (with some modifications that are enumerated in the linked document).

So we head over there… and discover that the Y comes from the <function-type> production of your "pointer to function" type, with the following explanation:

A "Y" prefix for the bare function type encodes extern "C" in implementations which distinguish between function types with "C" and "C++" language linkage. This affects only type mangling, since extern "C" function objects have unmangled names.

As for whether you have one of those implementations (I mean in general; clearly yours is one of them), this answer is worth a read.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • Thanks, you make it seem quite simple but not knowing much about mangling it was hard to search! :) – Kons Jun 14 '19 at 18:08
  • Also , it would be useful to have a practical example difference of the 2 possible declarations – Kons Jun 14 '19 at 18:13
  • Added in the question a snippet of code to generate both cases! – Kons Jun 14 '19 at 18:32
  • @Kons: You're welcome. The only thing I searched for was "ARM ABI" .. the rest was just reading and following clues. People rely too much on "searching" to jump straight to their answer; I really think they should do more _studying_! By taking you through my process, I'd hoped to show the value of that. Also... there's an example in the question I linked you to and suggested reading ;) – Lightness Races in Orbit Jun 14 '19 at 23:23
  • I'm up for all you've written, and although I'm an embedded C engineer I never had to look so closely to C++ mangling.. I would have never searched "ARM ABI" :D in the first place! Thanks again :) – Kons Jun 16 '19 at 18:16