__noreturn void __libc_init(void* raw_args,
                            void (*onexit)(void),
                            int (*slingshot)(int, char**, char**),
                            structors_array_t const * const structors) {
  KernelArgumentBlock args(raw_args);
  __libc_init_tls(args);
  __libc_init_common(args);

  apply_gnu_relro();

  // Several Linux ABIs don't pass the onexit pointer, and the ones that
  // do never use it.  Therefore, we ignore it.

  call_array(structors->preinit_array);
  call_array(structors->init_array);

  // The executable may have its own destructors listed in its .fini_array
  // so we need to ensure that these are called when the program exits
  // normally.
  if (structors->fini_array != NULL) {
    __cxa_atexit(__libc_fini,structors->fini_array,NULL);
  }

  exit(slingshot(args.argc, args.argv, args.envp));
}
Ejemplo n.º 2
0
__noreturn void __libc_init(uintptr_t *elfdata,
                            void (*onexit)(void),
                            int (*slingshot)(int, char**, char**),
                            structors_array_t const * const structors)
{
    int  argc;
    char **argv, **envp;

    /* Initialize the C runtime environment */
    __libc_init_common(elfdata);

    /* Several Linux ABIs don't pass the onexit pointer, and the ones that
     * do never use it.  Therefore, we ignore it.
     */

    /* pre-init array. */
    call_array(structors->preinit_array);

    /* .ctors section initializers, for non-arm-eabi ABIs */
    call_array(structors->ctors_array);

    // call static constructors
    call_array(structors->init_array);

    argc = (int) *elfdata;
    argv = (char**)(elfdata + 1);
    envp = argv + argc + 1;

    exit(slingshot(argc, argv, envp));
}
Ejemplo n.º 3
0
__noreturn void __libc_init(uintptr_t *elfdata,
                       void (*onexit)(void),
                       int (*slingshot)(int, char**, char**),
                       structors_array_t const * const structors)
{
    /* When we reach this point, all initializers have been already
     * run by the dynamic linker, so ignore 'structors'.
     */
    int     argc = (int)*elfdata;
    char**  argv = (char**)(elfdata + 1);
    char**  envp = argv + argc + 1;

    /* Several Linux ABIs don't pass the onexit pointer, and the ones that
     * do never use it.  Therefore, we ignore it.
     */

    exit(slingshot(argc, argv, envp));
}
/* This function is called from the executable's _start entry point
 * (see arch-$ARCH/bionic/crtbegin_dynamic.S), which is itself
 * called by the dynamic linker after it has loaded all shared
 * libraries the executable depends on.
 *
 * Note that the dynamic linker has also run all constructors in the
 * executable at this point.
 */
__noreturn void __libc_init(uintptr_t *elfdata,
                       void (*onexit)(void),
                       int (*slingshot)(int, char**, char**),
                       structors_array_t const * const structors)
{
    int     argc = (int)*elfdata;
    char**  argv = (char**)(elfdata + 1);
    char**  envp = argv + argc + 1;

    /* Several Linux ABIs don't pass the onexit pointer, and the ones that
     * do never use it.  Therefore, we ignore it.
     */

    /* The executable may have its own destructors listed in its .fini_array
     * so we need to ensure that these are called when the program exits
     * normally.
     */
    if (structors->fini_array)
        __cxa_atexit(__libc_fini,structors->fini_array,NULL);

    exit(slingshot(argc, argv, envp));
}
__noreturn void __libc_init(uintptr_t *elfdata,
                       void (*onexit)(void),
                       int (*slingshot)(int, char**, char**),
                       structors_array_t const * const structors)
{
    int  argc;
    char **argv, **envp;

    __libc_init_tls(NULL);

    /* Initialize the C runtime environment */
    __libc_init_common(elfdata);

    /* Several Linux ABIs don't pass the onexit pointer, and the ones that
     * do never use it.  Therefore, we ignore it.
     */

    /* pre-init array. */
    call_array(structors->preinit_array);

    // call static constructors
    call_array(structors->init_array);

    argc = (int) *elfdata;
    argv = (char**)(elfdata + 1);
    envp = argv + argc + 1;

    /* The executable may have its own destructors listed in its .fini_array
     * so we need to ensure that these are called when the program exits
     * normally.
     */
    if (structors->fini_array)
        __cxa_atexit(__libc_fini,structors->fini_array,NULL);

    apply_gnu_relro();
    exit(slingshot(argc, argv, envp));
}
Ejemplo n.º 6
0
void MouseTest( GLFWwindow* window, GameObjectBird *pBird, ScreenLine* pLine1, ScreenLine* pLine2, std::list<GameObject *>  gameObjectList  )
{

	// Quick and dirty test, if these work the rest do.
	// --> try move the mouse inside the window, click right, click left
	if (!pBird)
		return;
	
	if (pBird->bState==SLING)
	{
		pBird->pBody->SetActive(false);
		b2Vec2 newPos( PixelToMeter((float)slingX), PixelToMeter((float)slingY) );
		pBird->pBody->SetTransform( newPos, 0.0f );
	}

	double xpos;
	double ypos;

	static float lastXPos;
	static float lastYPos;
	// get mouse position
	glfwGetCursorPos( window, &xpos, &ypos);
	Camera *pCam = Camera::Instance();
	pCam;
	// correct for origin
	double t = ypos / 600.0;
	ypos = 600.0 + t * (-600.0);


	MouseState			mState = NONE;
	PositionState		pState = UNKNOWN;

	GameObject* b = pBird;
	Matrix viewMatrix = pCam->getViewMatrix();
	Matrix projMatrix = pCam->getProjMatrix();
	Matrix worldMatrix = b->pGameSprite->returnWorld();
	Vect vout = Vect(0.0f,0.0f,0.0f) * worldMatrix * viewMatrix * projMatrix; 
	float zoom = vout[w];
	
	vout[x] = vout[x]/vout[w];
	vout[y] = vout[y]/vout[w];

	float X = (vout[x]+1.0f)*(pCam->viewport_width/2.0f);
	float Y= (vout[y]+1.0f)*(pCam->viewport_height/2.0f);

	Vect birdPos(pBird->pos.x, pBird->pos.y,0.0f);
	Vect mousePos((float ) xpos,(float ) ypos, 0.0f);
	
	Vect local( X, Y, 0.0f);
	Vect Dist = mousePos - local;
	
	if ( Dist.mag() < (10.0f / zoom) )
	{
		pState = INSIDE;
	}
	else
	{
		pState = OUTSIDE;
	}
	//printf("%f - %f", Dist[x],Dist[y] );
	//printf("  |  %f - %f", X, Y );
	//xpos = xpos + Dist[x]*zoom;
	//ypos = ypos + Dist[y]*zoom;
	//printf("%f - %f ",xpos, ypos);
	mState = NONE;
	if( glfwGetMouseButton (window, GLFW_MOUSE_BUTTON_RIGHT ) == GLFW_PRESS)
	{
		mState = RIGHT;
	}

	if( glfwGetMouseButton (window, GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS)
	{
		
		mState = LEFT;
	}

	if (mState == LEFT && pBird->bState == NORMAL1)
	{
		pBird->bState = NORMAL2;
		pBird->onMouseAction();
		
	}

// Enter MOVING state
	if( mState == LEFT && pState == INSIDE)
	{
		;
		pBird->bState = MOVING;
		pBird->pBody->SetActive(false);
	}
	
	// small sublty here, once moving, left dictates mode
	if ( pBird->bState == MOVING)
	{
		if( mState == LEFT )//this drags the bird around
		{
			/*b2Vec2 newPos( PixelToMeter((float)xpos), PixelToMeter((float)ypos) );
			pBird->pBody->SetTransform( newPos, 0.0f );
			
			pLine1->posB=B;
			pLine2->posB=B;*/
			b2Vec2 slingPos(PixelToMeter((float)slingX), PixelToMeter((float)slingY));
			b2Vec2 newPos(PixelToMeter((float)pBird->pos.x+Dist[x]*zoom), PixelToMeter((float)pBird->pos.y+Dist[y]*zoom));
			
			b2Vec2 check(PixelToMeter((float)pBird->pos.x+Dist[x]*zoom-slingX), PixelToMeter((float)pBird->pos.y+Dist[y]*zoom - slingY));
			if (check.Length() > 2)
			{
				check.Normalize();
				newPos = slingPos + 2*check;
			}
			else
			{
				newPos.Set( PixelToMeter((float)pBird->pos.x+Dist[x]*zoom), PixelToMeter((float)pBird->pos.y+Dist[y]*zoom) );
			}
			//printf("%f - %f ",newPos.x, newPos.y);
			pBird->pBody->SetTransform( newPos, 0.0f );
			Vect2D B(MeterToPixel((float)newPos.x), MeterToPixel((float)newPos.y));
			pLine1->posB=B;
			pLine2->posB=B;	
		}
		else//this fires bird from the slingshot
		{	
			
			b2Vec2 slingshot(PixelToMeter(slingX-pBird->pos.x), PixelToMeter(slingY-pBird->pos.y));
			pBird->bState = NORMAL1;
			pBird->pBody->SetActive(true);
			float32 mag = slingshot.Length();
			if (mag>2)
				mag=2;
			slingshot.Normalize();
			if (pBird->pBody->GetMass()<10)
				mag*=20;
			else
				mag*=200;
			b2Vec2 vel;
			vel = mag * slingshot;
			pBird->pBody->ApplyLinearImpulse( vel, pBird->pBody->GetWorldCenter(), true );
			pBird->pBody->SetActive(true);
			Vect2D B(slingX, slingY) ;
			pLine1->posB=B;
			pLine2->posB=B;
			pBird->launch();
			AzulCore::clearTrails();
			std::list< GameObject *>::iterator it=gameObjectList.begin();
			while( it!=gameObjectList.end() )
			{
				GameObject *pGameObj = *it++;
				
				pGameObj->damageActive=true;
			}
		}
	}
	if (pBird->bState==SLING)
	{
		pBird->pBody->SetActive(false);
		b2Vec2 newPos( PixelToMeter((float)slingX), PixelToMeter((float)slingY) );
		pBird->pBody->SetTransform( newPos, 0.0f );
	}

	if (pBird->bState==SLING||pBird->bState==MOVING)
	{
		AzulCore::setTargetAndSpeed((slingX), (slingY), -0.2f,0.01f);
	}
	else 
	{
		AzulCore::setTargetAndSpeed(pBird->pos.x, pBird->pos.y, 0.1f,10.0f);
	}
		
}