{"action":"created","issue":{"url":"https://api.github.com/repos/bebbo/libnix/issues/12","repository_url":"https://api.github.com/repos/bebbo/libnix","labels_url":"https://api.github.com/repos/bebbo/libnix/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/bebbo/libnix/issues/12/comments","events_url":"https://api.github.com/repos/bebbo/libnix/issues/12/events","html_url":"https://github.com/bebbo/libnix/issues/12","id":438000845,"node_id":"MDU6SXNzdWU0MzgwMDA4NDU=","number":12,"title":"Is there a  way to bootstrap stdio without the regular linker magic?","user":{"login":"mheyer32","id":33539855,"node_id":"MDQ6VXNlcjMzNTM5ODU1","avatar_url":"https://avatars3.githubusercontent.com/u/33539855?v=4","gravatar_id":"","url":"https://api.github.com/users/mheyer32","html_url":"https://github.com/mheyer32","followers_url":"https://api.github.com/users/mheyer32/followers","following_url":"https://api.github.com/users/mheyer32/following{/other_user}","gists_url":"https://api.github.com/users/mheyer32/gists{/gist_id}","starred_url":"https://api.github.com/users/mheyer32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mheyer32/subscriptions","organizations_url":"https://api.github.com/users/mheyer32/orgs","repos_url":"https://api.github.com/users/mheyer32/repos","events_url":"https://api.github.com/users/mheyer32/events{/privacy}","received_events_url":"https://api.github.com/users/mheyer32/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2019-04-28T01:34:39Z","updated_at":"2019-05-02T18:48:23Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"DoomAttack loads plugins via LoadSeg. Thus, it requires the file to have a specific .o file first (it looks at the first few bytes for a magic word).\r\n\r\nDespite -nostartfiles -nodefaultlib -nostdlib, the regular GCC linker will put _something_ in front of the .o file containing the magic cookie, thus DoomAttack will not register it as plugin.\r\n\r\nI helped myself using  vlink to link the plugins from the produced .o files.\r\n\r\nFor many plugins, this is good enough - they don't use any stdlib stuff and are pretty barebones.\r\nBut some plugins want to do fancy things like printf.\r\nIt seems the plugins were written with MAXON-C and use a construct like below to get access to some standard libraries and the clib functionality:\r\n\r\n```\r\n\t\t#ifdef __MAXON__\r\n\t\tInitModules();\r\n\t\t#endif\r\n```\r\nWhen the plugin gets shut down, the reverse will be done:\r\n```\r\n\t#ifdef __MAXON__\r\n\tCleanupModules();\r\n\t#endif\r\n```\r\n\r\nNow the question is, does some mechanism like this exist for libnix (or GCC in general), too?\r\n\r\nI.e. can some code be loaded into memory and made fully functional? This is a weird scenario as the process that loads the code already has a working runtime environment for stdio etc...\r\n\r\nA similar scenario exists where if I spawn a new process  via CreateNewProcTags() also isn't properly setup to access stdlib functionality."},"comment":{"url":"https://api.github.com/repos/bebbo/libnix/issues/comments/488787735","html_url":"https://github.com/bebbo/libnix/issues/12#issuecomment-488787735","issue_url":"https://api.github.com/repos/bebbo/libnix/issues/12","id":488787735,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4ODc4NzczNQ==","user":{"login":"mheyer32","id":33539855,"node_id":"MDQ6VXNlcjMzNTM5ODU1","avatar_url":"https://avatars3.githubusercontent.com/u/33539855?v=4","gravatar_id":"","url":"https://api.github.com/users/mheyer32","html_url":"https://github.com/mheyer32","followers_url":"https://api.github.com/users/mheyer32/followers","following_url":"https://api.github.com/users/mheyer32/following{/other_user}","gists_url":"https://api.github.com/users/mheyer32/gists{/gist_id}","starred_url":"https://api.github.com/users/mheyer32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mheyer32/subscriptions","organizations_url":"https://api.github.com/users/mheyer32/orgs","repos_url":"https://api.github.com/users/mheyer32/repos","events_url":"https://api.github.com/users/mheyer32/events{/privacy}","received_events_url":"https://api.github.com/users/mheyer32/received_events","type":"User","site_admin":false},"created_at":"2019-05-02T18:48:23Z","updated_at":"2019-05-02T18:48:23Z","author_association":"CONTRIBUTOR","body":"https://github.com/mheyer32/DoomAttack/tree/Plugins\r\n\r\nHas it.\r\n\r\nmake music_doomsound\r\n\r\nshould produce a plugin inside ./bin/plugin/DAMusic_DoomSndLibrary.plugin  with its intermediate files in build/plugins/Sound_and_Music/DoomSound_Library/\r\n\r\nThe plugin's entry point is in funcs.c / C_DAM_Init()\r\nThe startup code I whipped up is in ./plugin_runtime.c\r\n\r\nDon't sweat it, its not super urgent :-)"}}
{"actor":{"display_login":"mheyer32"}}