@@ -29,6 +29,7 @@ static RCoreHelpMessage help_msg_is = {
2929 "is." , "" , "current symbol" ,
3030 "is*" , "" , "same as above, but in r2 commands" ,
3131 "isj" , "" , "in json format" ,
32+ "ise" , "" , "entrypoints symbols" ,
3233 NULL
3334};
3435
@@ -1847,6 +1848,88 @@ static bool fdof_cb(void *user, void *data, ut32 id) {
18471848 return true;
18481849}
18491850
1851+ static bool is_entrypoint_symbol (const char * name ) {
1852+ #if 0
1853+ On Swift any method can be an entrypoint if @main is used as attribute
1854+ #endif
1855+ const char * words [] = {
1856+ "main" , "_start" , "_main" , "Main" ,
1857+ "WinMain" , "wmain" , "DllMain" , "wWinMain" ,
1858+ "UIApplicationMain" ,
1859+ "applicationDidFinishLaunching" ,
1860+ "application:didFinishLaunchingWithOptions" ,
1861+ "applicationWillResignActive" ,
1862+ "applicationDidEnterBackground" ,
1863+ "applicationWillEnterForeground" ,
1864+ "applicationDidBecomeActive" ,
1865+ "applicationWillTerminate" ,
1866+ "application:configurationForConnectingSceneSession:options" ,
1867+ "application:didDiscardSceneSessions" ,
1868+ "application:openURL:options" ,
1869+ "application:performFetchWithCompletionHandler" ,
1870+ "application:didReceiveRemoteNotification:fetchCompletionHandler" ,
1871+ "application:handleEventsForBackgroundURLSession:completionHandler" ,
1872+ "application:shouldSaveSecureApplicationState" ,
1873+ "application:shouldRestoreSecureApplicationState" ,
1874+ "application:didRegisterForRemoteNotificationsWithDeviceToken" ,
1875+ "application:didFailToRegisterForRemoteNotificationsWithError" ,
1876+ "application:didReceiveRemoteNotification" ,
1877+ "application:handleOpenURL" ,
1878+ "application:continueUserActivity:restorationHandler" ,
1879+ "application:didUpdateUserActivity" ,
1880+ "scene:willConnectToSession:options" ,
1881+ "sceneDidDisconnect" ,
1882+ "sceneDidBecomeActive" ,
1883+ "sceneWillResignActive" ,
1884+ "sceneWillEnterForeground" ,
1885+ "sceneDidEnterBackground" ,
1886+ "application:handleWatchKitExtensionRequest:reply" ,
1887+ "main" ,
1888+ "loadView" ,
1889+ "viewDidLoad"
1890+ };
1891+ size_t i , size = sizeof (words ) / sizeof (words [0 ]);
1892+
1893+ for (i = 0 ; i < size ; i ++ ) {
1894+ if (!strcmp (name , words [i ])) {
1895+ return true;
1896+ }
1897+ }
1898+ return false;
1899+ }
1900+
1901+ static void cmd_ies (RCore * core , const char * input , PJ * pj , int mode , int va ) {
1902+ // iterate over symbols and class methods that match
1903+ RBinSymbol * sym ;
1904+ RVecRBinSymbol * symbols = r_bin_get_symbols_vec (core -> bin );
1905+ R_VEC_FOREACH (symbols , sym ) {
1906+ const char * name = r_bin_name_tostring2 (sym -> name , 'o' );
1907+ if (is_entrypoint_symbol (name )) {
1908+ r_cons_printf ("0x%08" PFMT64x " %s\n" , sym -> vaddr , name );
1909+ }
1910+ }
1911+ RList * bfiles = r_core_bin_files (core );
1912+ RBinFile * bf ;
1913+ RListIter * objs_iter ;
1914+ r_list_foreach (bfiles , objs_iter , bf ) {
1915+ RBinObject * obj = bf -> bo ;
1916+ RBinClass * klass ;
1917+ RListIter * iter , * iter2 ;
1918+ core -> bin -> cur = bf ;
1919+ RBinSymbol * method ;
1920+ r_list_foreach (obj -> classes , iter , klass ) {
1921+ r_list_foreach (klass -> methods , iter2 , method ) {
1922+ const char * name = r_bin_name_tostring2 (method -> name , 'o' );
1923+ if (is_entrypoint_symbol (name )) {
1924+ const char * kname = r_bin_name_tostring2 (klass -> name , 'o' );
1925+ r_cons_printf ("0x%08" PFMT64x " %s.%s\n" ,
1926+ method -> vaddr , kname , name );
1927+ }
1928+ }
1929+ }
1930+ }
1931+ }
1932+
18501933static void cmd_ie (RCore * core , const char * input , PJ * pj , int mode , bool is_array , int va ) {
18511934 char i1 = input [1 ];
18521935 if (i1 == ',' ) {
@@ -1856,6 +1939,8 @@ static void cmd_ie(RCore *core, const char *input, PJ *pj, int mode, bool is_arr
18561939 }
18571940 if (i1 == '?' ) {
18581941 r_core_cmd_help (core , help_msg_ie );
1942+ } else if (i1 == 's' ) {
1943+ cmd_ies (core , input , pj , mode , va );
18591944 } else if (i1 == ' ' || i1 == '*' || i1 == 'e' || i1 == 'j' || i1 == '=' || i1 == 'q' || !i1 ) {
18601945 RList * objs = r_core_bin_files (core );
18611946 RListIter * iter ;
0 commit comments