About the Author

me

I am a 24 year old Computer Science student at University of New Hampshire. I'm graduating in May, and currently searching for full time jobs. You can find my resume along with other info about me on my personal page: Daniel P. Noe.

 
-->

28 May 2007 - 10:53What is linux-gate.so.1 and why is it missing on x86-64?

On Linux systems, ldd is a command which displays information about which shared libraries are used by a particular executable. For example:

dpn@colobus:~$ ldd /bin/sh
        linux-gate.so.1 =>  (0xffffe000)
        libncurses.so.5 => /lib/libncurses.so.5 (0xb7f4c000)
        libdl.so.2 => /lib/libdl.so.2 (0xb7f48000)
        libc.so.6 => /lib/libc.so.6 (0xb7e24000)
        /lib/ld-linux.so.2 (0xb7f9c000)

This morning I read this page which gives an excellent explanation of what the “linux-gate” entry is (read the link for more background). Basically, it maps to a virtual shared library created by the kernel. The virtual shared library is used to select the best interface for performing a system call depending on what your CPU supports. Essentially, more modern x86 systems support a sysenter instruction which is significantly faster than the old method of generating an particular interrupt with the int instruction.

Naturally, I immediately tried what the article described on my workstation and was surprised to find no linux-gate.so.1 entry! That system is 64 bit (note the 64 bit addresses for libraries in the ldd output below).

dpn@tuna:~$ ldd /bin/sh
        libncurses.so.5 => /lib/libncurses.so.5 (0x00002ae3837c8000)
        libdl.so.2 => /lib/libdl.so.2 (0x00002ae383926000)
        libc.so.6 => /lib/libc.so.6 (0x00002ae383a2a000)
        /lib64/ld-linux-x86-64.so.2 (0x00002ae3836ab000)

To find out what is going on, I can run objdump -d on /lib64/libc-2.5.so, which I know will contain several system calls since it provided the most basic interface to kernel functionality. I redirected the output to a file and opened it in vim, searching through for a simple function which I know uses a syscall:


0000000000090ca0 :
   90ca0: b8 3f 00 00 00        mov    $0×3f,%eax
   90ca5: 0f 05                 syscall
   90ca7: 48 3d 01 f0 ff ff     cmp    $0xfffffffffffff001,%rax
   90cad: 73 01                 jae    90cb0 
   90caf: c3                    retq
   90cb0: 48 8b 0d 11 42 1a 00  mov    1720849(%rip),%rcx        # 234ec8 <_io_file_jumps +0x988>
   90cb7: 31 d2                 xor    %edx,%edx
   90cb9: 48 29 c2              sub    %rax,%rdx
   90cbc: 64 89 11              mov    %edx,%fs:(%rcx)
   90cbf: 48 83 c8 ff           or     $0xffffffffffffffff,%rax
   90cc3: eb ea                 jmp    90caf 
   90cc5: 90                    nop

This is the assembly code for the uname system call (I omitted 10 additional nop instructions at the end, presumably added by the compiler for alignment), which returns information about the current running kernel (such as version, etc). I can see from /usr/include/asm-x86_64/unistd.h that the system call number for uname is 63, which corresponds to 0×3f in hex. This is the value moved into the register eax at the start of the uname function. The kernel code looks into this register to determine which system call was executed. The next instruction is the syscall instruction. As you can see, the x86_64 architecture has an instruction called syscall which is directly defined as part of the architecture for all CPUs. Unlike x86, which had several different system call interfaces including the int instruction and the sysenter instruction, the virtual system call interface defined in linux-gate has no purpose on x86_64 systems.

One question remains. The uname system call takes one argument: A pointer to a utsname struct, which the kernel fills with data. But how is that argument passed to the kernel? The glibc function only sets up the system call number in eax. The answer is that in x86_64 arguments are passed in registers, beginning with rdi and rsi. So when the uname stub in glibc is called by a user program, rdi already contains the pointer to the utsname struct. The kernel just takes the pointer value out of rdi, where it remains untouched by the stub.

2 Comments | Tags: computers

24 May 2007 - 23:51Bush says we should leave Iraq if the Iraqis vote for it… which they did

I caught this short story today:

“We are there at the invitation of the Iraqi government. This is a sovereign nation. Twelve million people went to the polls to approve a constitution. It’s their government’s choice,’’ the president said during a Rose Garden news conference. “If they were to say leave, we would leave.”

Would somebody please remind the President and the Press that a little over two weeks ago the Iraqi Parliament called for a timetable for US withdrawal. If the President was being honest today about his support for the Iraqi government, he would be working with Congress to draw up a plan for a phased withdrawal. But instead he vetoed the spending bill which would have required timetables. Notably, that veto was only the second veto of his Presidency - the first being the Stem Cell Research Enhancement Act.

At this point the reality is painfully clear. The war isn’t about democracy at this point, if it ever was. It is now about saving face and holding off the inevitable long enough to push the whole mess onto someone else.

1 Comment | Tags: politics

22 May 2007 - 15:20Bourne Shell Programming.

Bourne Shell Programming.

This is the best shell programming tutorial I’ve found yet.

No Comments | Tags: extrafresh

16 May 2007 - 17:50Gonzales Ignored Senate Subpoena, Jail Likely?

Attorney General Gonzales was served a subpoena with a deadline of May 15th, 2PM, to appear before the Senate Judiciary Committee with documents required by the subpoena. Well, he didn’t show up, and no documents have been surrendered. Patrick Leahy and Arlen Specter, ranking Judiciary Committee members, responded with a letter stating an ultimatum of May 18th for the Attorney General to appear with the documents and a legal reason for missing the previous deadline.

Defying a Congressional Subpoena is called Contempt of Congress. It is a crime, punishable by up to a year in jail. If the Senate decides to pursue the charge of Contempt of Congress, they will ask the U.S. Attorney for the District of Columbia to bring Gonzales before a Grand Jury. Of course, the Bush Administration has made it quite clear that they believe they can obstruct ongoing investigations by absolute control over the Justice Department. So what happens if the Attorney General orders the U.S. Attorney not to bring him before the Grand Jury?

Legal precedent is definitely in favor of Congress. During the Harding Administration, Congress investigated the failure of the A.G. to investigate the Teapot Dome Scandal. Several cases went to the Supreme Court, and in McGrain v. Daugherty the Court granted broad powers to Congress, ruling that they had the power to broadly compel testimony.

Congress can also hold individuals for “inherent contempt.” In this case, the Sergeant-at-arms would actually go out and arrest Gonzales, bringing him to the committee chamber. The committee then has the power to compel testimony and imprison him for an indefinite period in the capitol jail. Of course, Congress hasn’t used this power in over 70 years, instead electing to use the Statutory process described above. But, they do in fact have the power to arrest an individual for Contempt and hold them.

Here is a hypothetical scenario discussed shortly after the 2006 Elections regarding the possibility of a investigative showdown. Seems like it is coming true, so far. The Bush Administrations defiance for Congressional Authority is a serious issue, undermining the very fabric of our Government.

Update: Looks like the hypothetical scenario linked above requires subscription unless you are coming from Google. Try this Google Search and look for “Will Nancy Pelosi put Alberto Gonzales behind bars?”

No Comments | Tags: politics

16 May 2007 - 11:36famfamfam.com: Silk Icons.

famfamfam.com: Silk Icons.

700 Free icons available under a Creative Commons license.

No Comments | Tags: extrafresh

16 May 2007 - 11:22Sesame Street Explains TCP

Sesame Street Explains TCP

No Comments | Tags: extrafresh

16 May 2007 - 8:18snakefood: Python Dependency Graphs

snakefood: Python Dependency Graphs

No Comments | Tags: extrafresh

15 May 2007 - 10:25Usability: Bank of America’s Online Account Access

I have a Visa credit card through Bank of America. A few months ago I noticed a recurring charge on my account which I couldn’t track to anything I was receiving or had agreed to pay for. I followed the normal procedure for challenging a charge and everything seems to have been dealt with. However, it did teach me an important lesson about monitoring charges closely. It is good to discover any fraudulent charges as soon as they occur. Because of this and other reasons, I use the Bank of America Online Account website to regularly check charges, pending charges, etc. I also pay my bills via the online website, choosing not to receive paper statements at all.

Bank of America started a promotion where their credit card customers could open a checking account and receive a $100 bonus from them. I decided to do this, and followed the procedure for opening the account online on Sunday night. Early Monday morning I received an email from Bank of America saying that my account application had been granted. Obviously they send things like the ATM/Debit card and PIN number through conventional mail, and of course I have yet to receive this information - it has been less than 18 hours since I applied for the account.

This morning I tried to access my Bank of America Online Account site to do my normal periodic check of any pending charges. But after entering my login information, I get a new page saying “Other Bank of America Accounts Detected: Enter ATM PIN.” This page required me to enter information about my new account - which I have not yet received - to continue and access information about my existing accounts. The bottom of the page gives my two choices: Continue (which doesn’t work because I can’t enter account information BoA hasn’t given me yet) or Cancel. If I click cancel, I get a page saying “You have decided not to continue which means you will be unable to access your accounts.” Which means I can’t access my existing account either, the one I have had access to for over a year now. The page also gives me a nice set of reasons I can give for why I decided to cancel, including “I don’t have all of the required information” and “I don’t have my ATM PIN.” Except no matter which you choose, it simply cancels the online account login and dumps me back at the Bank of America homepage.

New account form

What happens when you click cancel

Dear Bank of America: This behavior is broken. Clearly it takes longer for you to actually mail out the new account information than to send out an email saying “your account has been granted.” And clearly it also takes some amount of time for the US Postal Service to actually deliver that mail to me. Fortunately I have already payed my bill for this month, but what if I hadn’t? My experience has been that it can take up to a week or more for new account information to arrive in the mail. Because I choose to receive statements online (which, I might add, saves BoA costs), I don’t have a paper bill stub to send in a check with. So quite conceivably this bug could cause someone to miss a payment, causing the typical enormous late fees and sky high default APR.

I don’t understand how online banking sites get away with this shit. There is absolutely no reason why it should be necessary to completely block access to a customer’s online account access when they sign up for a new account. It doesn’t make sense from a technical standpoint, a security standpoint, or a usability standpoint. All you need to do to implement new account setup in the online account manager is to have a link on the main page of the online account site, after you log in. You can simply say “We show that you recently signed up for a new account. When you receive your account details, click here to add it to online banking.” This works far better from a usability standpoint, and it doesn’t lock a customer out of their own account management tools while waiting for BoA and the USPS. What if the postal service messed up and the new account mailing got lost? I’d be completely screwed, because it would inevitably be a very long time before I had access to my statements and bill pay tools.

I sent a comment in via their online account comment/bug report form. We’ll see what comes of it.

1 Comment | Tags: computers, money

11 May 2007 - 22:56Miss Katz

Miss Katz

Awww! Miss Katz is currently winning the cutest cat award.

Big Yawn

Look at those huge fangs! She is a fierce and wild animal!

And now back to your regularly scheduled programming…

No Comments | Tags: photos

11 May 2007 - 17:49No surprise: Responsible drinking at home ‘cuts bingeing’

No surprise: Responsible drinking at home ‘cuts bingeing’

No Comments | Tags: extrafresh

9 May 2007 - 20:28Cool business card designs

Cool business card designs

No Comments | Tags: extrafresh

9 May 2007 - 19:52So much for bringing democracy to Iraq

Here is an underreported story: A majority of the Iraqi Parliament have signed a legislative petition calling for a timetable for US withdrawal. Originally we went to war to get rid of the WMDs Saddam didn’t have. But after no WMDs were found the war’s supporters claimed we were bring democracy to the Middle East. Well, they have democracy, and the democratic decision is that the US should leave.

I haven’t seen this story widely reported at all. It puts pressure on both Congress and the Bush Administration to reconsider the war and plans for its end. It certainly isn’t good news for the US. Nobody can claim the Iraqi Parliament doesn’t have the support of the people, either. Apparently polls have regularly shown that the public in Iraq opposes the continuation of the US occupation.

The article also contains a simple indication of just how bad things are buried in parenthesis as a side note:

There are 275 members of the Iraqi parliament, but many have fled the country’s civil conflict, and at times it’s been difficult to arrive at a quorum.

The goal of spreading democracy in Iraq has ultimately been a failure as well. You can’t have a democratic process when the legislators fear for their lives. We’ve made a terrible mess. Around a year ago, I thought while things were bad in Iraq, they would get much worse if the US military left. I no longer think that. The US occupation has been so unhealthy for the country that it is imperative we leave, or at least begin the process. Iraq might benefit from western military assistance. But I think it needs to come from somewhere other than the US.

4 Comments | Tags: politics

9 May 2007 - 9:14Respect Weather

These pictures of supercell thunderstorms from the cockpit of an airliner are incredible. Supercell thunderstorms are the most severe type of thunderstorm, and they usually feature high winds and hail. They are also likely to spawn tornadoes. Usually at the altitudes commercial jet airliners fly at (30,000 ft+) you are above any weather. But in those photos you can see the anvil of the thunderstorm extending far above the aircraft at 36,000 ft. Click on the photos for larger versions.

Weather is an amazing force. Whether it is sailing, flying, or hiking in the White Mountains, any outdoor activity requires respect for weather. We understand an awful lot about weather systems, but thunderstorm activity and tornadoes are still difficult to predict with certainty. In the storm mentioned above the water droplets in the storm cloud are actually dense enough that the aircraft weather radar can’t penetrate through to the other side. Our technology is defeated by water. Fortunately, aircraft still have the ability to give storms plenty of room and go around them, and our ability to predict the general characteristics of storms has made flying much safer.

I often hear people complain about delays in commercial aviation which are caused by things like thunderstorms over the Great Plains. The fact is, pilots would rather stay on the ground and wait until they have a clear way across instead of risking contact with powerful storms. When large scale storms cross the country they affect the many routes taken by aircraft all across the country in complex ways which limit capacity. It is better to wait on the ground than in the air. The amount of fuel burned while flying a holding pattern is immense.

No Comments | Tags: scitech, aviation

9 May 2007 - 0:12If Congress voted according to their districts…

If members of Congress voted according to public opinion in their districts, there would be a a veto proof majority supporting a timetable for withdrawal from Iraq. This is yet another reason I think if things don’t turn around soon members of Congress will see the writing on the wall and try to rescue themselves before the next election.

Of course, this is based on an estimate and if you look into the calculations it isn’t a foolproof estimate. But support for the President is so low at this point, even amongst Republicans, that if Congress really wanted to they could send another timetable bill to the President and force him to veto it again. But what would that accomplish? The President has shown that he doesn’t believe in public opinion and he doesn’t care what Congress thinks about the war (never mind that the Constitution gives Congress the power both to declare war and to control the money spent on warfare). Unless a veto proof majority can actually be obtained, sending further bills to the President is just going to lead to bad blood. And if Bush’s veto is overturned, who knows what will happen? The Bush administration has shown so much contempt for Congressional Authority I almost wonder if you would see a constitutional crisis. Already the Bush administration has claimed “executive privilege” far broader than the US has ever experienced before. So much for checks and balances.

No Comments | Tags: politics

8 May 2007 - 23:25The White House’s exit strategy

In an interview with Charlie Rose, Condoleeza Rice said that “Iraqis need to know that we are not looking to leave Iraq.” What a telling statement. I think I know what the Whitehouse’s Iraq War strategy is at this point. Basically, they’re going to wait until 2009 when the next President is inaugurated… and then exit the White House smiling and leave the mess for someone else.

Political Blogger Kevin Drum has hypothesized that September will be judgment day for the Iraq War. With the 2008 elections approaching fast, congressional Republicans are unlikely to retain support for the increasingly unpopular war. Nationwide, support for the war and the President is very low. Yet, the Bush administration perseveres, seemingly oblivious to the slowly sinking approval rating.

ROSE: But nobody can answer the question: If it doesn’t happen, what?
RICE: Charlie, because as the President said to you, we’re focused on having it happen.

The administration is honestly not even considering the possibility that the war could be lost. And ultimately, we haven’t even defined what success or failure in Iraq even means. We went in with vague goals of nation building, which clearly weren’t even understood by Secretary of Defense Donald Rumsfeld, and we still don’t know how we define winning. I do think the war has made one thing clear — while we never took the time to plan what “success” means the current status of the war has done a wonderful job of indicating exactly what “failure” means. No matter what the future outcome of the war is, what has happened until now has been a failure, and I hope history won’t forget it.

Obviously Condoleeza Rice, the Secretary of State, believes that the only plan you need to have is to be “focused on having it happen.” Rice and the rest of the administration are living in a fantasy. I remember when people talked about Rice as being a viable Presidential candidate for 2008. Funny that nobody is talking about that now. Anyone with a hope of succeeding in 2008 needs to distance themselves as much as possible from the administration.

No Comments | Tags: politics

7 May 2007 - 19:49Record shops: Used CDs? Ihre papieren, bitte!

Record shops: Used CDs? Ihre papieren, bitte!

New legislation in several states has made selling used CDs more scrutinized than getting a driver’s license. I wonder what industry lobbying group had their hand in this?

No Comments | Tags: extrafresh

4 May 2007 - 9:16Barack Obama has requested that the Presidential debates be released under a Creative Commons license.

Barack Obama has requested that the Presidential debates be released under a Creative Commons license.

This would be really nice. There is really no reason why any commercial entity should have exclusive rights to the democratic process.

No Comments | Tags: extrafresh

4 May 2007 - 9:06The magic of …

The magic of …

Fox News quotes Obama with "…wants to play chicken with our troops." He actually said "I think that nobody wants to play chicken with our troops on the ground…" The lack of journalistic ethics and integrity is mind boggling.

No Comments | Tags: extrafresh

3 May 2007 - 1:22KC-135 Touch and Goes at Pease

Earlier this evening I did some work on my car and to test drive things I drove over to Pease (KPSM), our local big airport. Pease used to be an Air Force Base, but now it is open to the public. It is also still used by the 157th Air Refueling Wing of the NH Air National Guard. The Air Refueling Wing flies the Boeing KC-135 Stratotanker.

In Durham at UNH, one can frequently see KC-135s flying overhead at low altitude. They are easily recognizable by the refueling boom which is visible at the back. The reason why these aircraft frequently overfly Durham and Newmarket is because they are flying a air traffic pattern for one of the runways at Pease. They fly the pattern over and over again for training.

When I got to Pease I sat for a little while in the Park and Ride lot near the south end of the airport. This is at the beginning of Runway 34, which was the active runway since there was a brisk wind coming in from the north. I waited for a little while, watching the sunet, then spotted an aircraft headed south on a downwind leg over Durham. I watched as it turned to a base leg, then final. With such a big aircraft they set up for a long final and the base to final turn was barely visible. But, landing lights were clearly visible and I could tell the plane was definitely descending for landing on Runway 34. Soon it was quite close and at this point it was obvious it was a USAF KC-135.

KC-135 passing over the airport perimeter

Above you can see the plane passing over the ILS transmitted at the end of Runway 34. My camera has great zoom capabilities but at this point it was basically zoomed all the way out. The picture doesn’t do the size of the plane justice.

KC-135 about to touch-and-go

I watched as the plane touched down.. then, much to my surprise, the pilot took off again. This is called a touch-and-go and is frequently used during training since it allows you to make lots of take offs and landings, and generally practice the most important phases of flight. It was just a surprise to see touch and goes in such a large plane.. I had previously been used to seeing Cessnas at Boire Field in Nashua!

This time I could track the plane in my field of view the whole time it flew the pattern, then came in for another touch and go. Instead of watching from my car in the parking lot I crossed to the airport perimeter and watched from near the fence. It truly is impressive to see such a large plane coming in from so close. You could also clearly see the course corrections and wind affecting the aircraft during the short final approach. Of course, these are pilots in training so a bit of a rough landing is to be expected :)

Unfortunately by that time it was nearly dark, so no good pictures. You can check out the blurry ones, plus high-res versions of the others, in the gallery.

No Comments | Tags: photos, aviation

3 May 2007 - 0:51Replacing the distributor cap and rotor on the Accord

Earlier this evening I took advantage of nice weather to replace the distributor cap and rotor in my 1992 Honda Accord as part of an ongoing 150k mile service. Earlier I replaced the spark plugs. The distributor forms another part of the ignition system on this engine. The purpose of the distributor is to mechanically assign the spark voltage from the ignition coil to the particular cylinder that needs to fire. New cars sold today rarely have distributors, instead opting for full computer control with a separate coil for each cylinder (or shared by pairs of cylinders on some engines).

On my car the precise ignition timing is electronically controlled (it used to be fully mechanical on older cars). But the mechanical distributor is still used to assign the high voltage pulse to the cylinder that needs it. There is only a single coil, and the precise ignition firing is triggered by electronic sensors.

The distributor itself consists of a rotating shaft which is attached to the end of the camshaft. On the end of the shaft is a rotor, which is a plastic piece with a metal connection going from a contact in the middle to a contact at a particular point on the edge. The distributor cap has four metal contacts on the inside which are connected to the four spark plug wires. In the center is a contact which is connected to the coil. As the camshaft spins so does the rotor, synchronized with the rest of the engine. As the electronic ignition triggers an ignition signal, it is increased to high voltage by the coil and sent through the distributor, where everything has aligned to send the spark to the correct cylinder.

Since the distributor is a mechanical system, it is obviously subject to wear. My quick and dirty estimate indicates that the rotor inside the distributor will have made around 45,000,000 revolutions during 30,000 miles. Eventually the contacts wear out, grow dirty, and so on. Thus typically the rotor and the cap are considered wear parts and are replaced periodically when the ignition system is serviced.

Here is my old distributor on the engine. The spark plug wires have been removed for easy access to the annoying screw on the bottom. If you are going to try and replace the cap and rotor on this engine I highly recommend a stubby Phillips screwdriver. The job would have been much more frustrating without it since room is tight between the distributor cap screws and the airbox/cooling pipe on the left.

old distributor

old distributor

Once the distributor cap is removed you can see the rotor. The metal contact is visible at the top. On this car the rotor is simply held on the shaft with friction — a lot of friction. It did take considerable effort and prying to get the rotor off.

distributor with cap removed

The gray plastic dust cover covering some of the sensors inside was very brittle, likely due to age. It cracked and I was not able to reinstall it. It is only a $1.10 part.. but I think for now the purpose of the dust cover is pretty much redundant. I will include a replacement in my next parts order and install it then.

With the dust cover and rotor removed you can see the sensors inside. These electronic modules are used to detect the exact position of the camshaft so the spark timing can be adjusted. Precise timing of ignition provides big benefits in emissions, power, and fuel efficiency. Again, systems today are much, much more complex and sophisticated!

dust cover removed

Here is the finished product with the new distributor cap installed and the spark plug wires reconnected. You need to make sure you connect the wires in the correct order. The firing order is not 1-2-3-4! In fact, it is 1-3-4-2! That particular firing order was likely chosen to keep the engine’s operation smooth.

finished

You can find some ultra-high res images in the gallery.

whole engine bay

1 Comment | Tags: photos, automotive