0

I have a spidermonkey library that exports the following mangled symbol fora function JS_DefineProperty:

_Z17JS_DefinePropertyP9JSContextP8JSObjectPKcN2JS5ValueEPFiS0_NS5_6HandleIS2_EENS7_I4jsidEENS5_13MutableHandleIS6_EEEPFiS0_S8_SA_iSC_Ej

When I try to compile a file that uses this function, the external reference is compiled as:

_Z17JS_DefinePropertyP9JSContextP8JSObjectPKcN2JS5ValueEPFiS0_NS5_6HandleIS2_EENS7_IlEENS5_13MutableHandleIS6_EEEPFiS0_S8_S9_iSB_Ej

The end of the name is slightly different between the two. I ran both through a name demangler and they both come out to the same signature:

JS_DefineProperty(JSContext*, JSObject*, char const*, JS::Value, int (*)(JSContext*, JS::Handle, JS::Handle, JS::MutableHandle), int (*)(JSContext*, JS::Handle, JS::Handle, int, JS::MutableHandle), unsigned int)

So I'm a little stumped as to what the difference is. I believe both versions were compiled using g++ 4.7. Can anyone decode the extra difference in the name, so I can investigate further?

Shafik Yaghmour
  • 154,301
  • 39
  • 440
  • 740
gimmeamilk
  • 2,016
  • 5
  • 24
  • 36
  • according to http://pear.warosu.org/c++filtjs/ they decode to the same signature. – Ferenc Deak Jan 22 '14 at 13:56
  • @fritzone the website is wrong because it incorrectly escapes the templates (thinking they are html) – user3125280 Jan 22 '14 at 14:09
  • Yup... That's an interesting remark. Who reports this to that site? – Ferenc Deak Jan 22 '14 at 14:25
  • @fritzone it does not seem like there is a way to report it which is unfortunate since obviously people are using it to figure things out and we have at least one spurious SO question b/c the tool is broken. – Shafik Yaghmour Jan 22 '14 at 14:27
  • @fritzone actually the owner [can be contacted and has been](http://stackoverflow.com/questions/3006438/is-there-an-online-name-demangler-for-c). Take a look at the comments below the accepted answer. Also, make sure to downvote it or comment to remind him to fix this! The other answers there look useful. And use [this one](http://demangler.com/) instead – user3125280 Jan 22 '14 at 14:29
  • 1
    @user3125280 I forgot about that question and it is funny since I provided an answer to it as well. I recommended using `c++filt` on Coliru in that question which would not have the same problem. – Shafik Yaghmour Jan 22 '14 at 14:57

1 Answers1

3

There is in fact a difference between the two.

_Z17JS_DefinePropertyP9JSContextP8JSObjectPKcN2JS5ValueEPFiS0_NS5_6HandleIS2_EENS7_I4jsidEENS5_13MutableHandleIS6_EEEPFiS0_S8_SA_iSC_Ej demangles to :

JS_DefineProperty(JSContext*, JSObject*, char const*, JS::Value, int (*)(JSContext*, JS::Handle<JSObject*>, JS::Handle<jsid>, JS::MutableHandle<JS::Value>), int (*)(JSContext*, JS::Handle<JSObject*>, JS::Handle<jsid>, int, JS::MutableHandle<JS::Value>), unsigned int)

_Z17JS_DefinePropertyP9JSContextP8JSObjectPKcN2JS5ValueEPFiS0_NS5_6HandleIS2_EENS7_IlEENS5_13MutableHandleIS6_EEEPFiS0_S8_S9_iSB_Ej demangles to :

JS_DefineProperty(JSContext*, JSObject*, char const*, JS::Value, int (*)(JSContext*, JS::Handle<JSObject*>, JS::Handle<long>, JS::MutableHandle<JS::Value>), int (*)(JSContext*, JS::Handle<JSObject*>, JS::Handle<long>, int, JS::MutableHandle<JS::Value>), unsigned int)

Where the former is using JS::Handle<jsid>, the latter is using JS::Handle<long>.

Sander De Dycker
  • 16,053
  • 1
  • 35
  • 40
  • I get these resultss with c++filt as well, I assume that's how you got them? Maybe http://pear.warosu.org/c++filtjs/ doesn't work perfectly, even though it uses c++filt... – user3125280 Jan 22 '14 at 14:05
  • haha [it's a html thing](http://stackoverflow.com/questions/3006438/is-there-an-online-name-demangler-for-c) it must think the templates are tags – user3125280 Jan 22 '14 at 14:06
  • @user3125280 : that's correct - I used [c++filt](http://linux.die.net/man/1/c++filt) on my Linux system. – Sander De Dycker Jan 22 '14 at 14:08
  • Thank you! I was indeed using pear.warosu.org/c++filtjs – gimmeamilk Jan 22 '14 at 14:47