asked    Bridget     2018-10-22       c       75 view        1 Answer

[SOLVED] __attribute__((constructor)) how it change entry point?

I know that from the point of view of the C programming language main() is the entry point of the program.

But from the point of view of the operating system is __start at ctrt0 startup routines which are linked into a program that performs any initialization work required before calling the program's main() function (correct me if wrong here).

So we have some attributes which we can use for our functions, one of them is constructor attribute which is called before main(), who is responsible to call this function?

__attribute__((construtor))
void foo(void)
{
        puts("Constructor called by ... ?\n");
}

and how would it look in step by step call stack? Thanks!

  1 Answer  

        answered    Phoenix     2018-10-22      

Functions marked as "constructor" are placed in a special section in the executable file. The "start" function will then invoke those functions one by one, before it calls main.

The same with "destructor" functions, they are again placed in a special section and called by the code executing after exit is called or main returns.





Your Answer





 2018-10-22         Fabian

npm linked module listed as unmet dependency

I'm linking my-lib to see effects in my-app right away. cd my-lib-foldernpm linkcd ../my-app-foldernpm link my-libThis works as expected. Changes are picked up by my-app and I see the symlink in node_modules. My problem is that in my-app-folder/, npm list --link=true shows up empty. How can I get a list of the linked modules? npm ls my_libmy-app@3.1.0 /Users/path/my_project└── UNMET DEPENDENCY my-lib@3.7.0 npm ERR! missing: my-lib@3.7.0, required by my-app@3.1.0This happens both with Node 8 and 10 and their respective npm versions. OK, I realized that my-lib was somehow ...
 node.js                     1 answers                     50 view
 2018-10-22         Verna

how to refresh token when expired in jwt

I am implementing JWT in my project. I implemented jwt and gave it an expiration time of 1 minute. The jwt that is generated from the api side is during login and the token and expiration details are sent in the result and are stored in local storage. How can I refresh the expired token from API side and send it back again to the client so that it can be stored in local storage and sent for every call using interceptor?this is how I created jwt and gave expiration time// let us suppose this is my inputtokenObject = { User: { username: name, pwd: pwd } };//creating a jwt her...
 angularjs                     2 answers                     55 view
 2018-10-22         Sidney

Date format in Node

I just want to help with the print date like below.Thu Sep 06 2018 18:18:26 GMT+0530I used console.log(new Date())but Output of that is 2018-09-06T12:48:25.776ZSo, I don't know how to convert it. Thanks in advance. :) I used dateformat (npm install --save dateformat):const dateFormat = require('dateformat');console.log(dateFormat(new Date(), "ddd mmm dd yyyy HH:MM:ss UTC" ));Hope it helps. [XXX]You could use some third party module to do that, like moment or date-fns. Or create the string manually.For moment, see this: https://momentjs.com/docs/#/displaying/For date-f...
 node.js                     2 answers                     54 view